抱歉,我不知道您的目的,但显然您有激活用户的目的。
尝试一下,如果此解决方案不起作用,请告诉我您在控制器上的操作(activate_email)!
see on rake routes
输出 :
activate_email_users PUT /users/activate_email(.:format) users#activate_email
user GET /users/:id(.:format) users#show
当你生成
http://localhost:3000/users/activate_email?email_token=WWNvMN-r_lXgovrQiDlSSQ
你的问题是activate_email
被认为是:id
users/activate_email => users/:id
以及您问题的解决方案:
尝试删除method
从链接。最好指定method
在你的路线文件中。如何通过将路由替换为匹配:
resources :users do
member do
get :following,:followers
end
end
put "/users/activate_email/:email_token" => "users#activate_email", :as => "activate"
并在视图中
<%= link_to "Activate", activate_path(:email_token => @user.email_token) %>
我还没有测试过这个,但我想这就足够了。
UPDATE
对于问题:未定义的方法“protect_against_forgery?”
将其添加到只有您的邮件程序模板使用的帮助程序中:
def protect_against_forgery?
false
end
NOTE:如果您有新问题,请创建新的“提问”并批准答案对此问题有用