Sha256: b4fc162a32a24383e12fc7ee221dc5d4283e509bddc646a7a73fb8dcb18eeeb3
Contents?: true
Size: 1.91 KB
Versions: 22
Compression:
Stored size: 1.91 KB
Contents
module Kuhsaft module PagePart class Content < ActiveRecord::Base include Kuhsaft::Orderable belongs_to :localized_page serialize :content acts_as_taggable default_scope order('position ASC') class << self def serialize_attr name name = name.to_sym serializeable_attributes << name define_method name do self.content ||= {} self.content[name].presence end define_method "#{name}=" do |val| self.content_will_change! self.content ||= {} self.content[name] = val end end def searchable_attr name name = name.to_sym searchable_attributes << name end def searchable_attributes @searchable_attributes ||= [] end def serializeable_attributes @serializeable_attributes ||= [] end def page_part_types descendants end def to_name I18n.translate self.to_s.underscore.gsub('/', '.').downcase end end def edit_partial_path path = self.class.model_name.partial_path.split '/' path << "edit_#{path.pop}" path.join '/' #self.class.model_name.partial_path end def siblings self.localized_page.page_parts.where('id !=?', self.id) if self.localized_page.present? end def show_partial_path path = self.class.model_name.partial_path.split '/' path << "show_#{path.pop}" path.join '/' end private # # OMFG, OMFG!!! http://stackoverflow.com/questions/5178204/what-is-a-better-way-to-create-sti-model-instance # def atributes_protected_by_default super - [self.class.inheritance_column] end end end end
Version data entries
22 entries across 22 versions & 1 rubygems