0

Am trying to implement unsubscribe link to my rails mailer. I think the whole approach I have taken is wrong. What I take into consideration to implement Unsubscribe link to my rails mailer is from the following answers:

  1. https://stackoverflow.com/a/17886089/5614748
  2. https://stackoverflow.com/a/34779543/5614748

but didn't work for me and lead me to my question here

How can I successfully implement Unsubscribe key with my mailer?

Community
  • 1
  • 1
Afolabi Olaoluwa
  • 1,898
  • 3
  • 16
  • 37
  • Elaborate on "didn't work for me" – Sergio Tulentsev Nov 16 '16 at 08:56
  • [This one](http://stackoverflow.com/questions/17885502/how-to-generate-unsubscription-link-for-emails-of-actionmailer/17886089#17886089) is how I would do it. – Sergio Tulentsev Nov 16 '16 at 08:57
  • @SergioTulentsev if you check where I said it leads me through, you'll see your suggestion is all i have implemented but all to no avail – Afolabi Olaoluwa Nov 16 '16 at 09:46
  • You botched the implementation, unfortunately. This is not a flaw of that answer. If implemented correctly, it will work. Therefore, this question is not really valid. "What is the best way" - that way is good enough (as for me). – Sergio Tulentsev Nov 16 '16 at 10:02
  • @SergioTulentsev Okayyyy. But can you see through http://stackoverflow.com/questions/40614820/nomethoderror-in-usersunsubscribe/40615832?noredirect=1#comment68489231_40615832 probably you could see what I botched in the implementation ? – Afolabi Olaoluwa Nov 16 '16 at 11:37
  • Sure. unsubscribe link generation and fetching user by that token - these two are critical and both are wrong. There may be other flaws too. – Sergio Tulentsev Nov 16 '16 at 11:39
  • but if you say it is wrong, using `<%= link_to 'Unsubscribe Me!', unsubscribe_url(@user.unsubscribe_hash) %>` in my mailer preview, it gives me `NoMethodError in Rails::Mailers#preview` which is what brought what those guys are trying to fix in the link I supplied. – Afolabi Olaoluwa Nov 16 '16 at 12:29
  • This one is better. Now you just have to figure out why `@user` is nil – Sergio Tulentsev Nov 16 '16 at 12:33

0 Answers0