ruby on rails - Unable to over-write devise routes -
i using devise , want customize urls:
users/sign_in --> account/login users/sign_up --> account/register users/edit --> account/profile ...
now routes.rb
looks this:
devise_scope :user '/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 'account/password/forgot' => 'devise/passwords#new', as: :new_user_password 'account/password/edit' => 'devise/passwords#edit', as: :edit_user_password put 'account/password' => 'devise/passwords#update' 'account/cancel' => 'devise/registrations#cancel', as: :cancel_user_registration post 'account' => 'devise/registrations#create', as: :user_registration 'account/register' => 'devise/registrations#new', as: :new_user_registration 'account' => 'devise/registrations#edit', as: :edit_user_registration put 'account' => 'devise/registrations#edit' delete 'account' => 'devise/registrations#destroy' end devise_for :users
i manage over-write profile, forgot, register
bug not login
:
so when click on link "sign up" link in generic devise login form redirected /register
in browser, when click "sign in" link still redirected /users/sign_in
rather login
.
i tried match
vs. post + get
routes without luck. know if generate forms myself can decide how links like, prefer user generic devise forms , curious why other routes work.
running rake routes
produces (with top 5 rows routes):
new_user_session /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 /account/password/forgot(.:format) devise/passwords#new edit_user_password /account/password/edit(.:format) devise/passwords#edit account_password put /account/password(.:format) devise/passwords#update cancel_user_registration /account/cancel(.:format) devise/registrations#cancel user_registration post /account(.:format) devise/registrations#create new_user_registration /account/register(.:format) devise/registrations#new edit_user_registration /account(.:format) devise/registrations#edit account put /account(.:format) devise/registrations#edit delete /account(.:format) devise/registrations#destroy new_user_session /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 /users/password/new(.:format) devise/passwords#new /users/password/edit(.:format) devise/passwords#edit put /users/password(.:format) devise/passwords#update /users/cancel(.:format) devise/registrations#cancel post /users(.:format) devise/registrations#create /users/sign_up(.:format) devise/registrations#new /users/edit(.:format) devise/registrations#edit put /users(.:format) devise/registrations#update delete /users(.:format) devise/registrations#destroy root / posts#show
update: mimicking of devise's routes (see updated routes.rb). still redirected /users/sign_in
you can try this, working
see more devise wiki
devise_for :users, :path => '', :path_names => {:sign_in => 'login', :sign_out => 'logout'}
Comments
Post a Comment