ActionController::RoutingError (uninitialized constant User::UsersController) in heroku (but everything works in local)

无人久伴 提交于 2019-12-06 07:21:26

问题


I am trying to run my app in heroku but I get this error when trying to signup or even access devise's login page:

ActionController::RoutingError (uninitialized constant User::UsersController)

Is this a devise bug or a server setting i missed in heroku?

I am running a rails3.1 app in a cedar stack by the way and loading the index page is good, but if I try to login or sign up, it blows.

The signup form DOES show, but when I submit, that's when it blows. I checked the logs and it did POST to the controller but GETting the resulting page(when redirected I guess) blows it up.

Any help?

EDIT

here are my routes:

root :to => "home#index"

devise_for :users

namespace :user do
  root :to => "users#welcome"
end

resources :users, :only => :show

A heroku support person also asked about my routes but why does it happen in production only? Also I don't think there's any problem with the routes...is there?


回答1:


This is your problem:

namespace :user do
  root :to => "users#welcome"
end

Can you remove this?




回答2:


I found the you do not need to remove the default root for when a user logs in. So replace the namespace call and use the following:

match 'users' => 'users#welcome', :as => 'user_root'

This way you can still have two "home" pages. It worked for me.

https://github.com/plataformatec/devise/wiki/How-To%3a-Redirect-to-a-specific-page-on-successful-sign-in




回答3:


I got the same error. Error was only reproducible in Heroku, not locally. What I realized is that while I had added the resource to routes and pushed that, all the generated scaffold was still lying locally. Once I added all the generated stuff to git and pushed, worked fine on Heroku.



来源:https://stackoverflow.com/questions/6530471/actioncontrollerroutingerror-uninitialized-constant-useruserscontroller-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!