ActionController :: RoutingError(没有路由匹配[GET]“/ users / sign_up”)

时间:2012-08-02 15:04:15

标签: ruby-on-rails routing devise

我正在使用设计来管理我的rails应用中的用户帐户。它在我的开发环境中运行良好。当我导航到/ users / sign_up页面(users / sign_in正在工作)时,我只是推送到Heroku并且正在获取“您正在寻找的页面不存在”。我检查了日志并得到:

ActionController::RoutingError (No route matches [GET] "/users/sign_up")

我的routes.rb是:

  get "home/index"

  get "deals/new"
  get "deals/all"

  resources :deals

  devise_for :users

  root :to => "home#index"

知道出了什么问题吗?

由于

更新

路线是:

              home_index GET    /home/index(.:format)          home#index
               deals_new GET    /deals/new(.:format)           deals#new
               deals_all GET    /deals/all(.:format)           deals#all
                   deals GET    /deals(.:format)               deals#index
                         POST   /deals(.:format)               deals#create
                new_deal GET    /deals/new(.:format)           deals#new
               edit_deal GET    /deals/:id/edit(.:format)      deals#edit
                    deal GET    /deals/:id(.:format)           deals#show
                         PUT    /deals/:id(.:format)           deals#update
                         DELETE /deals/:id(.:format)           deals#destroy
        new_user_session GET    /users/sign_in(.:format)       devise/sessions#new
            user_session POST   /users/sign_in(.:format)       devise/sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy
           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        /                              home#index

更新

我在heroku上耙rake路线,结果非常不同。

home_index GET    /home/index(.:format)     home#index
 deals_new GET    /deals/new(.:format)      deals#new
 deals_all GET    /deals/all(.:format)      deals#all
     deals GET    /deals(.:format)          deals#index
           POST   /deals(.:format)          deals#create
  new_deal GET    /deals/new(.:format)      deals#new
 edit_deal GET    /deals/:id/edit(.:format) deals#edit
      deal GET    /deals/:id(.:format)      deals#show
           PUT    /deals/:id(.:format)      deals#update
           DELETE /deals/:id(.:format)      deals#destroy
      root        /                         home#index

似乎没有设置设计。我做错了什么?

5 个答案:

答案 0 :(得分:2)

在设计用户模型中:没有为生产环境设置registerable,但它适用于本地环境。这就是为什么它在本地工作而不会在Heroku上工作。

答案 1 :(得分:0)

我不确定使用“users”模型和“sign_up”默认使用什么类型的东西,但是如果你有一个名为sign_up的控制器方法,那么你可以添加

get "users/sign_up"

到routes.rb

如果要将用于sign_up的方法称为“create”,请尝试

match 'sign_up', :to => 'users#create'

答案 2 :(得分:0)

抱歉,我忽略了你使用设计的重点。 我认为注册路线应该是'/ registration / sign_up'

定义您自己的路线,请在routes.rb

中尝试
devise_scope :user do
  get "/sign_up" => "devise/registrations#new"
end

答案 3 :(得分:0)

devise_for :users, :path_names => {
   :sign_in => 'signin',
   :sign_out => 'signout',
   :sign_up => 'signup'
  },

答案 4 :(得分:0)

您的routes.rb文件中的

添加:

SELECT name
FROM table t1 
WHERE
    status = 'DE' and 
    start_date = '2016-12-01' AND 
    end_date = '2016-12-28' AND
    name IN (SELECT name FROM table t2 WHERE t1.name = t2.name status = 'PE' and start_date = '2017-02-01' AND end_date = '2017-02-28');

之后,请搜索路线,看看它是否存在。