How do you use an instance variable with a mailer in Ruby on Rails?

I created an instance variable (@user) in the mailer model and want to access it in the view? But this gives me an error (@user = nil). What is the best way to pass a variable to view (email body)?

Thanks Chirag

+3
source share
3 answers

If you want to access the instance variable in the mailer template, add in your mailer model

@body[:user] = user_object

@user, .

@user

, (text/html).

+7

I Rails 3 :

@user = user_object

@user, .

@user

,

mail(:from => "info@domain.info", :to => recipient, :subject => "Subject")
+4

view/email, body:-) , ,, body :account => recipient @account recipient, .

+2

Source: https://habr.com/ru/post/1729663/


All Articles