我使用的代码类似于密码重置,但我用它来“取消”'注册'。在这种情况下,带有令牌的链接正在邮寄给用户,他们点击该链接将其带到类似......
3000/cancel_registration/3Z9XWXExzZ3BzrpooI5flA/edit
......我在哪里......
#app/views/cancel_registration/edit.html.erb
<td><%= link_to 'Yes. Cancel my Registration', cancel_registration_path(@registration) %></td>
...在我的控制器中我有......
#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
...现在这就是我在控制器中的内容......
get 'cancel_registration', to: 'cancel_registration#new', as: 'cancel_registration'
post 'cancel_registration', to: 'cancel_registration#cancel', as: 'cancel_registration'
get工作正常,但不确定用户如何从我的视图中取消操作?
答案 0 :(得分:1)
您应该将http动词添加到链接:
link_to 'Yes. Cancel my Registration', cancel_registration_path(@registration), method: :post