Changing devise routes like '/users/sign_in' to '/sign_in'

In many of the applications built with the help of Devise sometimes you need to change the devise routes like '/users/sign_in' to simply '/sign_in'

1.)config/routes.rb
devise_for :users, :controllers => {registrations: 'registrations'}, :skip => [:sessions]
  devise_scope :user do
    get "/sign_up" => "devise/registrations#new", :as => :new_one_user_registration
    get '/sign_in' => "devise/sessions#new", :as => :new_user_session
    get '/forgot_password' => "devise/passwords#new", :as => :new_password
    get '/confirmation' => "devise/confirmations#new", :as => :new_confirmation
    post '/sign_in' => 'devise/sessions#create', :as => :user_session
    delete '/sign_out' => 'devise/sessions#destroy', :as => :destroy_user_session
    authenticated :user do
      root 'projects#index', as: :root
    end

    unauthenticated do
      root 'devise/sessions#new', as: :unauthenticated_root
    end
  end
end

Then define your path where you want it to be



Comments

Popular posts from this blog

Installing Wowza Streaming Engine on ubuntu

Highcharts with grouped categories

Completely Uninstall and Install Rubymine on ubuntu