Unsubscribe: Best practices

34 views
Skip to first unread message

Ralph Shnelvar

unread,
Jan 10, 2018, 6:24:31 AM1/10/18
to Ruby on Rails: Talk
I have a mailing list in a Postgres database and I want to give my users the ability to unsubscribe from mailings.

I wish to send out emails with a link to an RoR website to handle the unsubscribe.

Is there a document anywhere that describes how to do this properly?  That is, what the link in the email should look like and what the controller(s), routes.rb, and view(s) should look like?

Do I need to do a (implied) DELETE verb anywhere?

Ralph

Walter Lee Davis

unread,
Jan 10, 2018, 8:35:29 AM1/10/18
to rubyonra...@googlegroups.com
You don't (really) want a GET action to result in a DELETE, though, so I would recommend that rather than try to make the link in the e-mail delete the record immediately, take the user to a regular page, where you can construct a POST to DELETE, in the usual Rails manner (method: :delete). That gives a person a chance to reconsider, too, in case they fat-fingered the link in a mobile e-mail client.

Walter
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a72da346-e897-4eba-a9d0-1fac72ebf872%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Joe Guerra

unread,
Jan 10, 2018, 3:13:30 PM1/10/18
to Ruby on Rails: Talk
You basically need a boolean field in your mailing list table called subscribe.  

you can toggle that with true or false for the user by asking a question and flipping this bit.

As far as sending a link  - I already wrote this procedure.  It's quite easy.


basically have a controller that asks for the name and email address (capture that) , then send out a mailer with a link to the file you want.
I have my link to a file in the public folder (but the user isn't aware of that until he get's the email.)

Joe Guerra

unread,
Jan 10, 2018, 3:36:59 PM1/10/18
to Ruby on Rails: Talk
I think I have to push an update to this code.

I'm missing the deliver after creating the record.  I'll do that tonight.
Reply all
Reply to author
Forward
0 new messages