11
12
13
14
15
16
17
18
19
20
21
22
|
# 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 = ? AND author_id = ?", item.author_type, item.author_id]) }
end
end
|