1

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

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

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

4

5 回答 5

2

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

于 2012-08-04T13:36:21.273 回答
0

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

get "users/sign_up"

到路线.rb

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

match 'sign_up', :to => 'users#create'
于 2012-08-02T15:23:19.697 回答
0

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

要定义自己的路线,请在 routes.rb 中尝试

devise_scope :user do
  get "/sign_up" => "devise/registrations#new"
end
于 2012-08-02T15:43:09.103 回答
0
devise_for :users, :path_names => {
   :sign_in => 'signin',
   :sign_out => 'signout',
   :sign_up => 'signup'
  },
于 2012-08-02T15:53:14.570 回答
0

在您的 routes.rb 文件中添加:

     resource:users

之后做 rake 路线,看看它是否存在。

于 2017-01-09T19:39:52.460 回答