I have an ‘unsubscribe’ model where an unsubscribe record gets created when the user clicks on this link within the app:
link_to "Unsubscribe from comments on this post", post_unsubscribes_path(@post), method: :post
I would like to provide the same link in an email when the user gets notified of comments. The only problem is ‘method: post’ doesn’t work in an email (reverts to a ‘get’ request). Here is the controller:
class UnsubscribesController < ApplicationController def create post = Post.find(params[:post_id]) current_user.unsubscribes.create(post: post) redirect_to post_path(post), :notice => 'You are now unsubscribed from comments on this post.' end end
Any ideas on how to go about doing this from an email? I googled endlessly and I can’t find anything even though this seems like it would be pretty common. Do I need to change how I go about this in the controller?