Sha256: 69bb64998c93baf809e8b929d3c501011b4b0584cc8d61f9265771b904a8bc2a
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
class ContentPart < ActiveRecord::Base validates_presence_of :title, :body, :body_raw, :user_id validates_numericality_of :weight validates_uniqueness_of :permalink belongs_to :user belongs_to :category, :class_name => 'ContentCategory', :foreign_key => 'category_id' # for use as a post/summary post in conjunction with the excerpt has_one :image, :class_name => 'ContentImage', :dependent => :destroy has_one :image_overlay, :foreign_key => "content_part_as_overlay_id", :class_name => 'ContentImage', :dependent => :destroy default_scope :order => 'weight ASC, created_at DESC' before_validation :process_body, :create_permalink protected def create_permalink # do not update permalinks automatically. Ever. return unless self.permalink.blank? self.permalink = self.title.parameterize if self.permalink.blank? self.permalink = Digest::SHA1.hexdigest("fubar-#{Time.now.to_s}") end end def process_body self.body = self.body_raw end def image_path=(image) self.build_image :image => image end def image_path if self.image && self.image.image self.image.image.url else "" end end def image_overlay_path=(image) self.build_image_overlay :image => image end def image_overlay_path if self.image_overlay && self.image_overlay.image self.image_overlay.image.url else "" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spree-cms-0.1.0 | app/models/content_part.rb |