New Discussion

Notifications

You’re not receiving notifications from this thread.

Passing arguments to noticed Notifier config

0
Gems / Libraries

Hello, I watched the screencast and tried to follow the documentation but I can't seem to figure out this. I have a mailer ReservationMailer method that receives two arguments in its signature like so:

def reservation_reminder_email(reservation, purchase_prompt)
...

Then I have a ReservationReminderNotifier with a configuration like this:

  deliver_by :email do |config|
    config.mailer = "ReservationMailer"
    config.method = "reservation_reminder_email"
    config.args = -> { [record, purchase_prompt] }
  end

And I call it like this:

ReservationReminderNotifier.with(record: @reservation, purchase_prompt: "no").deliver(reservation.customer)

My understanding is that in this case config.args would be the arguments passed to the mailer however, what I can't figure out is how can I get the named parameters of the notifier (the ones in the with) within this configuration block so I can pass those as arguments to the mailer, if I try to reference record or purchase_prompt I get nothing.

Thanks in advance!

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 91,345+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.