Sha256: 4cd816adcc77cf7ab2716201ddb1c62296e141b9501e0b411dc59dcfdd6bb2d7
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 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' has_many :localizations, :class_name => "ContentPartLocalization", :dependent => :destroy # for use as a post/summary post in conjunction with the excerpt has_one :image, :class_name => 'ContentImage', :dependent => :destroy, :as => :content_part has_one :image_overlay, :foreign_key => "content_part_as_overlay_id", :class_name => 'ContentImage', :dependent => :destroy, :as => :content_part_as_overlay 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree-cms-0.2.1 | app/models/content_part.rb |
spree-cms-0.2.0 | app/models/content_part.rb |