forked from Gitlink/forgeplus
37 lines
854 B
Ruby
37 lines
854 B
Ruby
# == Schema Information
|
|
#
|
|
# Table name: feedback_message_histories
|
|
#
|
|
# id :integer not null, primary key
|
|
# feedback_id :integer
|
|
# user_id :integer
|
|
# title :string(255)
|
|
# content :text(65535)
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_feedback_message_histories_on_feedback_id (feedback_id)
|
|
# index_feedback_message_histories_on_user_id (user_id)
|
|
#
|
|
|
|
class FeedbackMessageHistory < ApplicationRecord
|
|
|
|
belongs_to :feedback
|
|
belongs_to :user
|
|
|
|
before_validation :send_meessage_email, on: :create
|
|
|
|
private
|
|
|
|
def send_meessage_email
|
|
unless UserMailer.feedback_email(feedback&.user&.mail, title, content).deliver_now
|
|
errors[:title] << '邮件发送失败!'
|
|
end
|
|
rescue
|
|
errors[:title] << '邮件发送失败!'
|
|
end
|
|
|
|
end
|