基本的に、誰かが私のアプリでフォームを送信したという通知をメールで送信する方法があります。最近、モデルを変更して、すべての割り当て(ユーザーが割り当てられている学校など)を処理するuser_designationsモデルを追加して、複数の人に通知できるようにしました。
方法:
def new_message(applicant)
@applicant = applicant
@applicant.school.users.each do |user|
mail(:to => user.email, :subject => "Submitted Application")
end
end
オブジェクト:
class Applicant
belongs_to :school
class School
has_many :applicants
has_many :user_designations
has_many :users, :through => :user_designations
class User
has_many :schools, :through => :user_designations
has_many :applicants, :through => :schools
メール関数は、ループの最後の反復でのみ機能します。私もエラーが発生しています:
#School:0x007fe064700890の未定義のメソッド `user'
この少量の情報に基づくアイデアはありますか?