remove pictures required

This commit is contained in:
benji 2015-02-10 13:04:35 +01:00
parent f37bc6acb0
commit f745de8153
3 changed files with 19 additions and 17 deletions

View file

@ -17,14 +17,15 @@
class Product < ActiveRecord::Base
has_many :order_items
has_attached_file :avatar, styles: { medium: "100x100>" }, default_style: :medium
has_attached_file :avatar, styles: { medium: "100x100>" }, default_style: :medium, default_url: "http://lorempixel.com/70/70/"
enum category: %w(food beverages other)
validates :name, presence: true
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, presence: true, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] }
validates_attachment :avatar, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] }
# validates_attachment :avatar, presence: true
def price
self.price_cents / 100.0

View file

@ -31,14 +31,15 @@ class User < ActiveRecord::Base
has_paper_trail only: [:balance, :admin, :orders_count, :koelkast]
has_attached_file :avatar, styles: { medium: "100x100>" }, default_style: :medium
has_attached_file :avatar, styles: { medium: "100x100>" }, default_style: :medium, default_url: "http://lorempixel.com/70/70/"
has_many :orders, -> { includes :products }
has_many :products, through: :orders
belongs_to :dagschotel, class_name: 'Product'
validates :nickname, presence: true, uniqueness: true
validates_attachment :avatar, presence: true, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] }
validates_attachment :avatar, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] }
# validates_attachment :avatar, presence: true
scope :members, -> { where koelkast: false }

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,32 +41,32 @@ 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',
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')
}
]