Added photo model

This commit is contained in:
Gopesh Tulsyan 2014-06-10 12:43:15 +05:30
parent 0f697f3dbe
commit 69ddea47dd
6 changed files with 62 additions and 1 deletions

View file

@ -42,7 +42,7 @@ class Conference < ActiveRecord::Base
has_many :vchoices, :dependent => :destroy
has_many :sponsorship_levels, dependent: :destroy
has_many :sponsors, dependent: :destroy
has_many :photos, dependent: :destroy
belongs_to :venue
accepts_nested_attributes_for :rooms, :reject_if => proc {|r| r["name"].blank?}, :allow_destroy => true

11
app/models/photo.rb Normal file
View file

@ -0,0 +1,11 @@
class Photo < ActiveRecord::Base
attr_accessible :picture, :description
belongs_to :conference
validates_presence_of :picture
has_attached_file :picture,
styles: { thumb: '100x100>', large: '300x300>' }
validates_attachment_content_type :picture,
content_type: [/jpg/, /jpeg/, /png/, /gif/],
size: { in: 0..500.kilobytes }
end