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


i created instance variable (@user) in model of mailer , want access in view? it's giving me an error (@user = nil). what's best way pass variable view (the email body)?

thanks, chirag

if want access instance variable in mailer template in mailer model add

@body[:user] = user_object 

the above create instance variable @user can accessed in view. should able access user object in mailer view doing

@user 

the docs here have examples of alternative ways if using multiple formats (text/html).


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -