Reputation: 5355
I am using code that is similar to a password reset, but I am using it to 'cancel' a 'registration'. In this case a link with a token is being mailed to the user, and they click on that link which takes them to something like...
3000/cancel_registration/3Z9XWXExzZ3BzrpooI5flA/edit
...where I have...
#app/views/cancel_registration/edit.html.erb
<td><%= link_to 'Yes. Cancel my Registration', cancel_registration_path(@registration) %></td>
...in my controller I have...
#app/controllers/cancel_registration_controller.rb
def edit
@registration = Registration.find_by_registration_cancellation_token!(params[:id])
end
def cancel
puts "made it to cancel"
end
...right now here is what I have in my controller...
get 'cancel_registration', to: 'cancel_registration#new', as: 'cancel_registration'
post 'cancel_registration', to: 'cancel_registration#cancel', as: 'cancel_registration'
The get works fine, but not sure how to the the user to the cancel action from my view?
Upvotes: 0
Views: 35
Reputation: 7043
You should add the http verb to the link:
link_to 'Yes. Cancel my Registration', cancel_registration_path(@registration), method: :post
Upvotes: 1