re-add pictures

This commit is contained in:
benji 2015-02-17 15:35:15 +01:00
parent 7bbf93741b
commit 78a0ae15bf
4 changed files with 17 additions and 17 deletions

View file

@ -25,7 +25,7 @@ class Product < ActiveRecord::Base
validates :price_cents, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
validates :stock, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
validates_attachment :avatar, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] }
# validates_attachment :avatar, presence: true
validates_attachment :avatar, presence: true
def price
self.price_cents / 100.0

View file

@ -31,7 +31,7 @@ class User < ActiveRecord::Base
has_paper_trail only: [:balance, :admin, :orders_count, :koelkast]
has_attached_file :avatar, styles: { medium: "100x100>" }, default_style: :medium, default_url: "http://lorempixel.com/70/70/"
has_attached_file :avatar, styles: { large: "190x190>", medium: "100x100>" }, default_style: :medium, default_url: "http://lorempixel.com/70/70/"
has_many :orders, -> { includes :products }
has_many :products, through: :orders
@ -41,7 +41,7 @@ class User < ActiveRecord::Base
validates :name, presence: true
validates :last_name, presence: true
validates_attachment :avatar, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] }
# validates_attachment :avatar, presence: true
validates_attachment :avatar, presence: true
scope :members, -> { where koelkast: false }

View file

@ -5,6 +5,6 @@
<% end %>
<% end %>
<%= link_to image_tag(user.avatar , class: "img-circle avatar"), new_user_order_path(user) %>
<%= link_to image_tag(user.avatar(:large) , class: "img-circle avatar"), new_user_order_path(user) %>
<%= link_to user.name , new_user_order_path(user), class: "btn btn-info", style: get_color_style(user) %>
</div>

View file

@ -13,22 +13,22 @@ products = [
name: 'Fanta',
price: 0.6,
category: 'beverages',
stock: 25
# avatar: File.new('public/seeds/products/fanta.jpg', 'r')
stock: 25,
avatar: File.new('public/seeds/products/fanta.jpg', 'r')
},
{
name: 'Club Mate',
price: 1.2,
category: 'beverages',
stock: 25
# avatar: File.new('public/seeds/products/club_mate.jpg', 'r')
stock: 25,
avatar: File.new('public/seeds/products/club_mate.jpg', 'r')
},
{
name: 'Kinder Bueno',
price: 0.6,
category: 'food',
stock: 15
# avatar: File.new('public/seeds/products/bueno.jpg', 'r')
stock: 15,
avatar: File.new('public/seeds/products/bueno.jpg', 'r')
}
]
@ -41,34 +41,34 @@ users = [
nickname: 'admin',
name: 'A.',
last_name: 'Admin',
# avatar: File.new('public/seeds/users/admin.jpg', 'r'),
avatar: File.new('public/seeds/users/admin.jpg', 'r'),
admin: true
},
{
nickname: 'koelkast',
name: 'K.',
last_name: 'Koelkast',
# avatar: File.new('public/seeds/users/admin.jpg', 'r'),
avatar: File.new('public/seeds/users/admin.jpg', 'r'),
koelkast: true
},
{
nickname: 'benji',
name: 'Benjamin',
last_name: 'Cousaert',
# avatar: File.new('public/seeds/users/benji.jpg', 'r'),
avatar: File.new('public/seeds/users/benji.jpg', 'r'),
dagschotel: Product.first
},
{
nickname: 'don',
name: 'Lorin',
last_name: 'Werthen'
# avatar: File.new('public/seeds/users/don.jpg', 'r')
last_name: 'Werthen',
avatar: File.new('public/seeds/users/don.jpg', 'r')
},
{
nickname: 'silox',
name: 'Tom',
last_name: 'Naessens'
# avatar: File.new('public/seeds/users/silox.jpg', 'r')
last_name: 'Naessens',
avatar: File.new('public/seeds/users/silox.jpg', 'r')
}
]