如何定义Rails路由但不允许URL访问它

时间:2016-11-22 20:59:39

标签: ruby-on-rails

如果我定义了“注销”路线,那么我可以创建一个注销 按钮去那条路。

但我不希望用户从“localhost:3000 / logout”这样的URL访问此路由,我该怎么做?

感谢。

1 个答案:

答案 0 :(得分:1)

将其添加到config / routes.rb文件中:

post '/logout', to: 'auth#logout', as: 'auth_logout'

您应该阅读:Rails Routing from the Outside In