11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/sunrise/models/feedback_message.rb', line 11
def self.extended(base)
base.class_eval do
has_many :answers, :class_name => 'FeedbackAnswer', :foreign_key => :message_id, :dependent => :delete_all
belongs_to :author, :polymorphic => true
before_validation :make_author
default_scope order("#{quoted_table_name}.id DESC")
scope :recently, order("#{quoted_table_name}.created_at DESC")
scope :with_author, lambda { |item| where(:author_type => item.author_type, :author_id => item.author_id) }
scope :with_email, lambda { |email| where(:user_email => email) }
scope :with_phone, lambda { |phone| where(:phone_number => phone) }
end
end
|