在rake路线中的路线,但页面说没有路线匹配[GET]与设计

时间:2013-10-30 03:53:40

标签: ruby-on-rails devise

我已为设计操作添加了自定义路由。当我尝试转到/ profile / edit或/ login或/ logout时这不起作用这是rake路线:

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

这是我的routes.rb文件,其中我为设计添加了具有相同控制器操作的新路由:

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" }

然后页面说明并且应该路由到设计控制器:

Routing Error

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

1 个答案:

答案 0 :(得分:0)

我不知道这是否正确,但我认为你不能这样做,因为Devise没有任何控制器。请检查questionthis

我通常做的是为Devise制作另一个控制器,或像users_controller这样的普通控制器,它拥有视图。并在routes.rb上注册,如:

devise_for :users

scope "/admin" do
  resources :users
end

然后当我需要打开它时,我打电话给localhost:3000/admin/users

但如果有什么不妥,请纠正我,否则我的方法是错的。希望可以提供帮助。