Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Exhibit < ActiveRecord::Base
- acts_as_list
- has_many :images, :through => :image_associations
- has_many :image_associations, :as => :associable, :dependent => :destroy
- has_many :calendar_items, :as => :calendarable, :dependent => :destroy
- belongs_to :created_by, :class_name => "User", :foreign_key => "created_by"
- belongs_to :updated_by, :class_name => "User", :foreign_key => "updated_by"
- def begin_date_string
- self.begin_date ? self.begin_date.to_s(:standard) : Time.now.to_s(:standard)
- end
- def begin_date_string=(date)
- self.begin_date = Date.parse(date)
- end
- def end_date_string
- self.end_date ? self.end_date.to_s(:standard) : Time.now.to_s(:standard)
- end
- def end_date_string=(date)
- self.end_date = Date.parse(date)
- end
- def image_attributes=(attributes)
- if image = Image.create(attributes)
- self.image_associations.create(:image => image)
- end
- end
- def calendar_item_attributes=(attributes)
- calendar_item = self.calendar_items.build
- calendar_item.update_attributes(attributes)
- end
- end
Add Comment
Please, Sign In to add comment