When someone submits an application, we should be notified by email that an application has been submitted.
We should also send an email to the user telling them that we have received their application and linking them to the show page (user mentee application). We should also send a notification to the admin to let them know a new application has been submitted.
I propose we use the existing pattern used on pair_request acceptance.
def create
...
ActiveRecord::Base.transaction do
@user_mentee_application.save!
current_user.resumes.create!(resume: resume_params[:resume], name: resume_params[:resume_name], current: true)
end
redirect_to @user_mentee_application, notice: 'Application succesfully submitted'
send_notifications
...
end
private
def send_notifications
UserMenteeApplication::ApplicationSubmittedNotification.with(user_mentee_application: @user_mentee_application).deliver(@user_mentee_application.user)
end
Pros:
class ApplicationSubmittedNotification < Noticed::Base
deliver_by :email,
mailer: "UserMailer",
method: :application_submitted
param :user_mentee_application
def users_to_notify
[params[:user_mentee_application].user, *User.admin]
end
end