2015-08-20 10:38:22 +08:00
|
|
|
class UserFeedbackMessage < ActiveRecord::Base
|
|
|
|
attr_accessible :journals_for_message_id, :journals_for_message_type, :user_id, :viewed
|
|
|
|
|
|
|
|
belongs_to :journals_for_message
|
|
|
|
belongs_to :user
|
2015-08-24 22:47:48 +08:00
|
|
|
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
|
2015-08-20 10:38:22 +08:00
|
|
|
|
|
|
|
validates :user_id,presence: true
|
|
|
|
validates :journals_for_message_id,presence: true
|
|
|
|
validates :journals_for_message_type, presence: true
|
2015-09-01 15:23:30 +08:00
|
|
|
after_save :add_user_message
|
2015-08-24 22:47:48 +08:00
|
|
|
|
|
|
|
def add_user_message
|
|
|
|
self.message_alls << MessageAll.new(:user_id => self.user_id)
|
|
|
|
end
|
2015-08-20 10:38:22 +08:00
|
|
|
end
|