0

I have added custom routes for the devise actions. this does not work when I try to go to /profile/edit or /login or /logout Here is the rake routes:

saasbook@saasbook:~/Documents/ronde$ rake routes
        static_about GET      /static/about(.:format)                static#about
         static_tour GET      /static/tour(.:format)                 static#tour
         static_home GET      /static/home(.:format)                 static#home
 static_terms_of_use GET      /static/terms_of_use(.:format)         static#terms_of_use
      static_contact GET      /static/contact(.:format)              static#contact
       users_profile GET      /users/profile(.:format)               registrations#edit
               login GET      /login(.:format)                       devise/sessions#new
              logout GET      /logout(.:format)                      devise/sessions#destroy
            register GET      /register(.:format)                    devise/registrations#new
        profile_edit GET      /profile/edit(.:format)                devise/registrations#edit
    new_user_session GET      /users/sign_in(.:format)               devise/sessions#new
        user_session POST     /users/sign_in(.:format)               devise/sessions#create
destroy_user_session GET      /users/sign_out(.:format)              devise/sessions#destroy
user_omniauth_authorize GET|POST /users/auth/:provider(.:format)        omniauth_callbacks#passthru {:provider=>/google|facebook/}
user_omniauth_callback GET|POST /users/auth/:action/callback(.:format) omniauth_callbacks#(?-mix:google|facebook)
       user_password POST     /users/password(.:format)              devise/passwords#create
   new_user_password GET      /users/password/new(.:format)          devise/passwords#new
  edit_user_password GET      /users/password/edit(.:format)         devise/passwords#edit
                     PUT      /users/password(.:format)              devise/passwords#update
cancel_user_registration GET      /users/cancel(.:format)                devise/registrations#cancel
   user_registration POST     /users(.:format)                       devise/registrations#create
 new_user_registration GET      /users/sign_up(.:format)               devise/registrations#new
edit_user_registration GET      /users/edit(.:format)                  devise/registrations#edit
                     PUT      /users(.:format)                       devise/registrations#update
                     DELETE   /users(.:format)                       devise/registrations#destroy
                root          /                                      static#home

Here is my routes.rb file where I added the the new routes with the same controller actions for devise:

Ronde::Application.routes.draw do

get "static/about"
get "static/tour"
get "static/home"
get "static/terms_of_use"
get "static/contact"
get "/user/profile", :to => 'registrations#edit'
get "/login", :to => "devise/sessions#new" # Add a custom sign in route for user sign in
get "/logout", :to => "devise/sessions#destroy" # Add a custom sing out route for user sign out
get "/register", :to => "devise/registrations#new" # Add a Custom Route for Registrations
get "profile/edit", :to => "devise/registrations#edit"

devise_for :users, :controllers => { :omniauth_callbacks =>  "omniauth_callbacks" }


root to: 'static#home'
end

# :path_names => {:edit => "profile/edit", :sign_in => "login", :sign_out => "logout",     :sign_up => "register" }

Then page says that and should route to the devise controller:

Routing Error

No route matches [GET] "/profile/edit"
Try running rake routes for more information on available routes.

1 Answers1

0

I don't know if this right but I think you can't do that way, because Devise doesn't have any controller. Please check this question and this.

What I done usually was making another controller for Devise, or normal controller like users_controller with it own views. And register it on routes.rb like:

devise_for :users

scope "/admin" do
  resources :users
end

Then when I need to open it, I called localhost:3000/admin/users

But please correct me if there anything wrong, or my way to do it was wrong. Hope can help.

Community
  • 1
  • 1
ksugiarto
  • 940
  • 1
  • 17
  • 40