Sha256: 474f2a2253e01ad2ebf9e3800dc9e754079e4541044fde7c3e31e50530270e6d
Contents?: true
Size: 1014 Bytes
Versions: 1
Compression:
Stored size: 1014 Bytes
Contents
module SimplePages class Page < ActiveRecord::Base self.table_name = SimplePages.page_table_name attr_reader :owner attr_accessible :title, :excerpt, :content, :published_at, :owner, :layout_at validates :url, presence: true validates :title, presence: true belongs_to :author, polymorphic: true has_many :attachments, as: :resource acts_as_url :title scope :published, lambda { where('published_at <= ?', Time.zone.now) } class << self def find_or_create_by_url(attrs) url = attrs.delete(:url) page = find_by_url(url) if page.nil? page = create(attrs) page.url = url page.save end page end end def to_param url end def owner=(attrs) owner_attrs = attrs.split(',') self.author_type = owner_attrs.first self.author_id = owner_attrs.last end SimplePages.page_modules.each do |module_name| include module_name end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple-pages-rails-0.0.1 | app/models/simple_pages/page.rb |