设计更改默认路由不起作用
当我关注 Devise Wiki https://github.com/plataformatec/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes ,我的默认路由名称根本没有改变,这里是我的代码:
MyApp::Application.routes.draw do
root :to => "profile#index"
devise_for :users
namespace :user do
root :to => "profile#index"
end
as :user do
get "/login" => "devise/sessions#new"
get "/signup" => "devise/registrations#new"
end
两个路线更改不起作用,所以我停下来。
我如何更改它,以便我的路线为:
/users/sign_in = /login
/users/sign_up = /signup
/users/sign_out = /signout
/users/edit = /edit
我正在使用 Devise 1.3.4 和 Rails 3.0.7 。
先感谢您!
when i follow the Devise Wiki at https://github.com/plataformatec/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes , my default route names do not change at all, here is my code :
MyApp::Application.routes.draw do
root :to => "profile#index"
devise_for :users
namespace :user do
root :to => "profile#index"
end
as :user do
get "/login" => "devise/sessions#new"
get "/signup" => "devise/registrations#new"
end
The two route changes didnt work so i stopped.
How do i change it so my routes are:
/users/sign_in = /login
/users/sign_up = /signup
/users/sign_out = /signout
/users/edit = /edit
I am using Devise 1.3.4 and Rails 3.0.7.
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我明白了,我只是输入这个来帮助其他新手!
路线本身会改变,但导航链接不会改变,除非以这种方式编码。
尝试 http://localhost:3000/login 和 http://localhost:3000/users/sign_up,它们是相同的,但只需手动输入即可。
我的新代码如下所示(导航链接和路线配置在一起):
routes.rb:
views/devise/menu/_login_items.html.erb :
views/devise/menu/_registration_items.html.erb
我当然希望这能帮助那些像我一样迷失方向并刚刚接触 devise 和 RoR 的人。它将让您更好地了解如何以简单的方式让路线看起来像您想要的那样,但仍然有效。祝你好运!
OK i figured it out, ill just type this out to help other newbies!
The routes themselves change but not the navigation links unless coded that way.
try http://localhost:3000/login and http://localhost:3000/users/sign_up, they are the same thing but just have to be typed in manually.
My new code looks like this ( navigation links & route configurations together):
routes.rb:
the views/devise/menu/_login_items.html.erb :
the views/devise/menu/_registration_items.html.erb
I certainly hope this helps people who were lost like me and just got into both devise and RoR. it will give you a good understanding on how to get the routes to look the way you want it to be in a simple manner, yet still work. Good luck!
这些维基页面是非常好的资源。
https://github。 com/plataformatec/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes
介绍如何更改登录/注销路线,但这也可以轻松应用于注册。看看
These wiki pages are very good resources.
https://github.com/plataformatec/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes
Tells how to change login/logout routes but that can easily be applied to signup too. Take a look