socialforge/app/models/user_feedback_message.rb

17 lines
560 B
Ruby
Raw Normal View History

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
validates :user_id,presence: true
validates :journals_for_message_id,presence: true
validates :journals_for_message_type, presence: true
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
end