Sha256: 4cf5cb9bf7721093056d23a18b77be56a76f5bef5611e37740c1f6ef9ff44491
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
class SimpleContentManagement::SimplePage < ActiveRecord::Base include SimpleContentManagement::ContentText has_many :simple_routes, conditions: { deleted: false }, class_name: "SimpleContentManagement::SimpleRoute" attr_accessible :name, :title, :content_html, :simple_routes_list scope :active, where(deleted: false) def simple_routes_list path_names.join "," end def simple_routes_list=(routes_list) path_names = routes_list.split "," # destroy routes that are no longer required self.simple_routes.each do |simple_route| simple_route.destroy unless path_names.include? simple_route.path end # ensure any existing routes are set active to the current page. SimpleContentManagement::SimpleRoute.where(path: path_names).each do |simple_route| simple_route.simple_page = self simple_route.deleted = false simple_route.save path_names.delete simple_route.path end # create the remaining routes path_names.each do |path_name| self.simple_routes.build path: path_name end end def path_names simple_routes.pluck("path") end def destroy update_attribute :deleted, true end def label title end class << self def registered_content_pages @registered_content_pages ||= YAML.load_file File.join Rails.root, "config", "content_pages.yml" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
th_simple_content_management-0.2.2 | app/models/simple_content_management/simple_page.rb |