app/helpers/mailkick/url_helper.rb in mailkick-0.3.0 vs app/helpers/mailkick/url_helper.rb in mailkick-0.3.1
- old
+ new
@@ -1,13 +1,14 @@
module Mailkick
module UrlHelper
- def mailkick_unsubscribe_url(email: nil, list: nil, **options)
- email ||= controller.message.to.first
+ def mailkick_unsubscribe_url(email: nil, user: nil, list: nil, **options)
+ email ||= controller.try(:message).try(:to).try(:first)
+
Mailkick::Engine.routes.url_helpers.url_for(
(ActionMailer::Base.default_url_options || {}).merge(options).merge(
controller: "mailkick/subscriptions",
action: "unsubscribe",
- id: Mailkick.generate_token(email, list: list)
+ id: Mailkick.generate_token(email, user: user, list: list)
)
)
end
end
end