Search code examples
ruby-on-rails-3mailer

Pass @to_whom and @from_whom to a Rails 3 mailer


How can i pass two users (@to_whom and @from_whom) to a mailer from the controller. I have only been able to get one passed, e.g.:

UserMailer.invitation_email(@to_whom).deliver

Thanks.


Solution

  • You can pass multiple parameters:

    UserMailer.invitation_email(@to_whom, @from_whom).deliver
    

    Just make sure your invitation_email method is set up to accept all the parameters:

    def invitation_email(to_whom, from_whom)
      ...
    end