Sha256: e95deea048cbe1213238649a7c8b3b9a9bf7d247b44d7d136e36c26000049e15

Contents?: true

Size: 463 Bytes

Versions: 2

Compression:

Stored size: 463 Bytes

Contents

class Page < Section
  has_one :article, :foreign_key => 'section_id', :inverse_of => :section, :dependent => :destroy
  validates_presence_of :article
  accepts_nested_attributes_for :article
  before_validation :ensure_default_article

  def body=(body)
    ensure_default_article
    article.body = body
  end

  protected

    def ensure_default_article
      build_article(:site => site, :section => self, :title => name) unless article.present?
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
adva-core-0.0.2 app/models/page.rb
adva-core-0.0.1 app/models/page.rb