我正在使用设计,我想自定义它的网址:
users/sign_in --> account/login
users/sign_up --> account/register
users/edit --> account/profile
...
现在我的routes.rb
样子是这样的:
devise_scope :user do
get '/account/login' => 'devise/sessions#new'
post 'account/login' => 'devise/sessions#create', as: :user_session
delete 'account/logout' => 'devise/sessions#destroy', as: :destroy_user_session
post 'account/password' => 'devise/passwords#update', as: :user_password
get 'account/password/forgot' => 'devise/passwords#new', as: :new_user_password
get 'account/password/edit' => 'devise/passwords#edit', as: :edit_user_password
put 'account/password' => 'devise/passwords#update'
get 'account/cancel' => 'devise/registrations#cancel', as: :cancel_user_registration
post 'account' => 'devise/registrations#create', as: :user_registration
get 'account/register' => 'devise/registrations#new', as: :new_user_registration
get 'account' => 'devise/registrations#edit', as: :edit_user_registration
put 'account' => 'devise/registrations#edit'
delete 'account' => 'devise/registrations#destroy'
end
devise_for :users
我设法不覆盖profile, forgot, register
错误login
:
因此,当我单击通用设计登录表单中的“注册”链接时,我在浏览器中被重定向到,/register
但是当我单击“登录”链接时,我仍然被重定向到/users/sign_in
而不是login
.
我尝试了路线,但没有match
运气post + get
。我知道如果我自己生成表格,我可以决定链接的外观,但我更喜欢使用通用设计表格,而且我很好奇为什么其他路线有效。
运行rake routes
会产生这个(我的路线中的前五行):
new_user_session GET /account/login(.:format) devise/sessions#new
user_session POST /account/login(.:format) devise/sessions#create
destroy_user_session DELETE /account/logout(.:format) devise/sessions#destroy
user_password POST /account/password(.:format) devise/passwords#update
new_user_password GET /account/password/forgot(.:format) devise/passwords#new
edit_user_password GET /account/password/edit(.:format) devise/passwords#edit
account_password PUT /account/password(.:format) devise/passwords#update
cancel_user_registration GET /account/cancel(.:format) devise/registrations#cancel
user_registration POST /account(.:format) devise/registrations#create
new_user_registration GET /account/register(.:format) devise/registrations#new
edit_user_registration GET /account(.:format) devise/registrations#edit
account PUT /account(.:format) devise/registrations#edit
DELETE /account(.:format) devise/registrations#destroy
new_user_session GET /users/sign_in(.:format) devise/sessions#new
POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
POST /users/password(.:format) devise/passwords#create
GET /users/password/new(.:format) devise/passwords#new
GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
GET /users/cancel(.:format) devise/registrations#cancel
POST /users(.:format) devise/registrations#create
GET /users/sign_up(.:format) devise/registrations#new
GET /users/edit(.:format) devise/registrations#edit
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
root / posts#show
更新:我现在正在模仿设计的所有路线(请参阅更新的 routes.rb)。但我仍然被重定向到/users/sign_in