I want to notify the user by email when an action occurs using ActionMailer.

However, under the current situation, the following error will be displayed and the mail will not be sent correctly.
As it is written below, if you hit the address solidly, an email will be sent.

Reference ①
Reference ②

By the way, I implemented it with reference to this area.

I would appreciate it if you could tell me the solution including the cause of the error.

Corresponding source code
class TargetMailer</pre>
<pre><code>## idealweight_controller
class IdealweightsController</pre>
Your registration is complete
<!-Content is appropriate->
What I tried

If i solidify the user's address, an email will be sent without any error.

class TargetMailer
Supplementary information (FW/tool version, etc.)

ruby 2.5.1

  • Answer # 1

    I have created an email column in the user model, but I have not created it in this ideal weight model.

    With that@ idealweight.emailI don't think it can be done,`@idealweightSince the user_id column exists in, if it is linked with model@ idealweight.user.emailI feel that I can get the email I expected at. In other words, how about the following?

    mail (subject: "You have registered a goal", to: @ idealweight.user.email)

Related articles