Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninitialized constant Rolify::Adapter::Scopes #83

Closed
adamtrilling opened this issue Jun 10, 2012 · 4 comments
Closed

uninitialized constant Rolify::Adapter::Scopes #83

adamtrilling opened this issue Jun 10, 2012 · 4 comments
Labels
Milestone

Comments

@adamtrilling
Copy link

I am attempting to use the following setup for a new app:

rails 3.2.5
mongoid 2.4.11
devise 2.1.0
cancan 1.6.7
rolify 3.2.0.rc1

This was all generated using rails_apps_composer, except that I modified the authorization recipe to use rolify 3.2.0.rc1 from github (it currently points to 3.2.0.beta4, which doesn't appear to exist on rubygems). The template runs the rolify:role generator correctly, but whenever I try to run any rake task that depends on environment, I get the following exception:

** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant Rolify::Adapter::Scopes
/Users/adam/code/testapp/app/models/role.rb:18:in <class:Role>' /Users/adam/code/testapp/app/models/role.rb:1:in<top (required)>'
/Users/adam/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/mongoid-2.4.11/lib/rails/mongoid.rb:73:in `load_model'
.
.
.

@ghost ghost assigned EppO Jun 12, 2012
@EppO
Copy link
Member

EppO commented Jun 12, 2012

you're definitely right, rolify 3.2.0.beta4 was never released on rubygems, only committed this version on github.
Currently trying to reproduce the issue on my system.
Can you copy/paste or make a gist of your user and resource classes ?
Thanks for your feedback, very appreciated.

@adamtrilling
Copy link
Author

The issue as I encountered it won't reproduce anymore, because rails_app_composer added a workaround:

RailsApps/rails_apps_composer@0056877

The changes are in recipes/devise.rb and recipes/add_user.rb. TL;DR: they are using rolify 3.1.0 and adding extend Rolify after the line include Mongoid::Document.

That line should probably be inserted by your rolify:role generator so the workaround isn't required.

Here's a gist with my (now working) User.rb:

https://gist.github.com/2919964

I haven't tried any more recent versions of rolify, so I don't know if this is even still an issue...the comment in the above diff implied that it isn't as of 3.2.0.beta4, but it failed for me in 3.2.0.rc1.

@EppO EppO closed this as completed in 38f4205 Jun 12, 2012
@EppO
Copy link
Member

EppO commented Jun 12, 2012

Can you try it again please with the latest master branch version ? it should be fixed.
You will have to re-run the generator again to have an updated Role class version including the new scopify method instead of the include of the module. The method loads properly the ORM adapter files depending the ORM you use.

@adamtrilling
Copy link
Author

It works fine with the latest master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants