Devise Invitable: uninitialized constant

不想你离开。 提交于 2019-12-04 20:37:28

问题


I'm using devise, wich works fine, now I try to use devise_invitable. I installed it correctly, but I'm getting the error when I try to access

http://localhost:3000/users/invitation/new

The error is:

Started GET "/users/invitation/new" for 127.0.0.1 at 2011-07-06 20:47:07 -0300

ActionController::RoutingError (uninitialized constant Users):


Rendered /Users/Fernando/.rvm/gems/ruby-1.9.2-head/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.9ms)


The routes looks like ok, and I dont know why it return this error.

Routes:

accept_user_invitation
GET    /users/invitation/accept(.:format)
   {:action=>"edit", :controller=>"devise/invitations"}

user_invitation
POST   /users/invitation(.:format)              
   {:action=>"create", :controller=>"devise/invitations"}

new_user_invitation 
GET    /users/invitation/new(.:format)          
   {:action=>"new", :controller=>"devise/invitations"}

回答1:


Actually, you must stick your invitations controller within a users directory under app/controllers for this to work.

So you would end up with:

/app/controllers/users/invitations_controller.rb

Doing this will get rid of that unitialized constant error.




回答2:


Try changing

devise_for :users, controllers: { invitations: 'users/invitations' }

to

devise_for :users, controllers: { invitations: 'devise/invitations' }


来源:https://stackoverflow.com/questions/6604383/devise-invitable-uninitialized-constant

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