Skip to content

Instantly share code, notes, and snippets.

@theinventor
Created March 27, 2012 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save theinventor/2216360 to your computer and use it in GitHub Desktop.
Save theinventor/2216360 to your computer and use it in GitHub Desktop.
def unsubscribe
token = Base64.decode64(params[:token]) #using base64 encoding in the url to prevent unsubscribe abuse
@user = User.find_by_access_token(token) #find the user from the ID in url
@user.opt_out = true #change them to not get email
@user.save #save the changes
redirect_to "/", :notice => "We won't bug you with emails!" #give them a little notice that it worked
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment