module Kuztuscms class Page < ActiveRecord::Base belongs_to :layout, :foreign_key => :layout_id, :class_name => 'Layout' belongs_to :article, :foreign_key => :article_id, :class_name => 'Article' validates :name, :path, :layout_id, :article_id, :presence => true validates :default, :uniqueness => true, :if => :default class << self def default where(:default => true) end end end end