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