Sha256: be49c2266296277bc7710c5d755dd7aa8857c19217f32b1d0d88810268f548e7
Contents?: true
Size: 990 Bytes
Versions: 19
Compression:
Stored size: 990 Bytes
Contents
module Spina class PagePart < ActiveRecord::Base include ApplicationHelper belongs_to :page belongs_to :page_partable, polymorphic: true accepts_nested_attributes_for :page_partable, allow_destroy: true attr_accessor :position validates_presence_of :name, :page_partable_type, :title validates_uniqueness_of :name, scope: :page_id scope :sorted, -> { order(:position) } def to_s name end def position(theme) page_parts = theme.config.view_templates[self.page.try(:view_template) || "show"][:page_parts] page_parts.index { |page_part| page_part == self.name }.to_i end def content self.page_partable.try(:content) || self.page_partable end def page_partable_attributes=(attributes) if self.page_partable.present? self.page_partable.assign_attributes(attributes) else self.page_partable = self.page_partable_type.constantize.new(attributes) end end end end
Version data entries
19 entries across 19 versions & 1 rubygems