Module: Sunrise::Models::Question::ClassMethods

Defined in:
lib/sunrise/models/question.rb

Class Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sunrise/models/question.rb', line 11

def self.extended(base)
  base.class_eval do
    belongs_to :structure
    
    validates_presence_of :title, :content
    validates_numericality_of :sort_order, :only_integer => true, :allow_nil => true
   
   scope :sortable, order("#{quoted_table_name}.sort_order DESC")
   scope :recently, order("#{quoted_table_name}.created_at DESC")
   scope :visible, where(:is_visible => true)
  end
end