generator fails with mongoid and rolify (3.3.0.rc4 34c56d7) #165

Closed
yacc opened this Issue Jun 28, 2013 · 6 comments

Projects

None yet

6 participants

@yacc
yacc commented Jun 28, 2013

rails g rolify Role User -o mongoid
invoke mongoid
create app/models/role.rb
invoke rspec
create spec/models/role_spec.rb
invoke machinist
append spec/support/blueprints.rb
/Users/yacin/.rvm/gems/ruby-1.9.3-p125@stripemetrics/gems/mongoid-3.1.2/lib/mongoid/relations/options.rb:42:in block in validate!': (Mongoid::Errors::InvalidOptions) Problem: Invalid option :join_table provided to relation :roles. Summary: Mongoid checks the options that are passed to the relation macros to ensure that no ill side effects occur by letting something slip by. Resolution: Valid options are: after_add, after_remove, autosave, before_add, before_remove, dependent, foreign_key, index, order, primary_key, class_name, counter_cache, extend, inverse_class_name, inverse_of, name, relation, validate, make sure these are the ones you are using. from /Users/yacin/.rvm/gems/ruby-1.9.3-p125@stripemetrics/gems/mongoid-3.1.2/lib/mongoid/relations/options.rb:36:ineach'

my bundle:
Gems included by the bundle:

  • actionmailer (3.2.12)
  • actionpack (3.2.12)
  • activemodel (3.2.12)
  • activerecord (3.2.12)
  • activeresource (3.2.12)
  • activesupport (3.2.12)
  • addressable (2.3.3)
  • arel (3.0.2)
  • bcrypt-ruby (3.0.1)
  • better_errors (0.7.2)
  • binding_of_caller (0.7.1)
  • bootstrap-sass (2.3.1.0)
  • builder (3.0.4)
  • bundler (1.3.5)
  • cancan (1.6.9)
  • capybara (2.0.2)
  • childprocess (0.3.9)
  • coderay (1.0.9)
  • coffee-rails (3.2.2)
  • coffee-script (2.2.0)
  • coffee-script-source (1.6.1)
  • database_cleaner (0.9.1)
  • debug_inspector (0.0.2)
  • diff-lcs (1.2.1)
  • email_spec (1.4.0)
  • erubis (2.7.0)
  • execjs (1.4.0)
  • faraday (0.8.6)
  • ffi (1.4.0)
  • figaro (0.6.3)
  • font-awesome-sass-rails (3.0.2.2)
  • haml (4.0.1.rc.1)
  • haml-rails (0.4)
  • hashie (1.2.0)
  • hike (1.2.1)
  • hpricot (0.8.6)
  • html2haml (1.0.1)
  • httpauth (0.2.0)
  • i18n (0.6.4)
  • journey (1.0.4)
  • jquery-rails (2.2.1)
  • json (1.7.7)
  • jwt (0.1.8)
  • launchy (2.2.0)
  • machinist (2.0)
  • machinist_mongo (2.0.0.beta.1 fa4819c)
  • mail (2.4.4)
  • mime-types (1.21)
  • mongoid (3.1.2)
  • mongoid-rspec (1.7.0)
  • moped (1.4.3)
  • multi_json (1.6.1)
  • multipart-post (1.2.0)
  • nokogiri (1.5.6)
  • oauth2 (0.8.1)
  • omniauth (1.1.3)
  • omniauth-oauth2 (1.1.1)
  • omniauth-stripe-connect (2.2.0)
  • origin (1.0.11)
  • polyglot (0.3.3)
  • quiet_assets (1.0.2)
  • rack (1.4.5)
  • rack-cache (1.2)
  • rack-protection (1.5.0)
  • rack-ssl (1.3.3)
  • rack-test (0.6.2)
  • rails (3.2.12)
  • railties (3.2.12)
  • rake (10.0.3)
  • rdoc (3.12.2)
  • redis (3.0.3)
  • redis-namespace (1.2.1)
  • resque (1.23.1)
  • resque-lock (1.1.0)
  • resque-scheduler (2.0.0)
  • rest-client (1.6.7)
  • rolify (3.3.0.rc4 34c56d7)
  • rspec (2.13.0)
  • rspec-core (2.13.1)
  • rspec-expectations (2.13.0)
  • rspec-mocks (2.13.0)
  • rspec-rails (2.13.0)
  • ruby_parser (3.1.1)
  • rubyzip (0.9.9)
  • rufus-scheduler (2.0.18)
  • sass (3.2.7)
  • sass-rails (3.2.6)
  • selenium-webdriver (2.31.0)
  • sexp_processor (4.1.5)
  • simple_form (2.1.0)
  • sinatra (1.3.6)
  • sitemap_generator (4.1.0)
  • spork (1.0.0rc3)
  • spork-rails (3.2.1)
  • sprockets (2.2.2)
  • stripe (1.7.11 ce34d9e)
  • stripe_event (0.6.0)
  • thor (0.17.0)
  • tilt (1.3.5)
  • treetop (1.4.12)
  • tzinfo (0.3.37)
  • uglifier (1.3.0)
  • vegas (0.1.11)
  • websocket (1.0.7)
  • xpath (1.0.0)
@EppO
Member
EppO commented Aug 27, 2013

I tried your setup using ruby MRI 1.9.3p448, rails 3.2.12, mongoid 3.1.2 and rolify master branch, and I couldn't reproduce your issue:

rails g rolify Role -o=mongoid
      invoke  mongoid
      create    app/models/role.rb
      invoke    rspec
      create      spec/models/role_spec.rb
      invoke      machinist
      append        spec/support/blueprints.rb
      insert    app/models/role.rb
      insert  app/models/user.rb
      create  config/initializers/rolify.rb
===============================================================================

An initializer file has been created here: config/initializers/rolify.rb, you
can change rolify settings to match your needs.
Defaults values are commented out.

A Role class has been created in app/models (with the name you gave as
argument otherwise the default is role.rb), you can add your own business logic
inside.

Inside your User class (or the name you gave as argument otherwise the default
is user.rb), rolify method has been inserted to provide rolify methods.

The only main difference I see between our setup is the use of machinist_mongo gem as I couldn't find it if you can point me on the repo you used.

@EppO EppO was assigned Aug 27, 2013
@srilumpa

Hi,

I had the same error, but using rolify v3.3.0.rc5

$ rails g rolify Role -o mongoid
/app/vendor/cache/mongoid-60a46908c248/lib/mongoid/relations/options.rb:42:in `block in validate!':  (Mongoid::Errors::InvalidOptions)
Problem:
  Invalid option :join_table provided to relation :roles.
Summary:
  Mongoid checks the options that are passed to the relation macros to ensure that no ill side effects occur by letting something slip by.
Resolution:
  Valid options are: after_add, after_remove, autosave, before_add, before_remove, dependent, foreign_key, index, order, primary_key, class_name, counter_cache, extend, inverse_class_name, inverse_of, name, relation, validate, make sure these are the ones you are using.

Using rails g rolify Role -o mongoid or rails g rolify Role User -o mongoid had the same effect.... Until I noticed I had already added rolify in my User model before generating the Role model. Removing the line fixed it and I could run the rails command smoothly.

@EppO
Member
EppO commented Feb 1, 2014

can you please check with rolify 3.4 or master branch and reopen this bug if that still occurs ? thanks

@EppO EppO closed this Feb 1, 2014
@micho
micho commented Feb 10, 2014

I'm getting a similar error with rolify 3.4 and master.

@diegodorado

This error is happening because the rolify initializer is loded late, and because Rolify.orm default is "active_record".
Managed to bypass the error renaming the initializer to "01_rolify.rb" to load it first

@EppO EppO was unassigned by yacc Jul 3, 2014
@simlegate

@diegodorado yes, you are right!! Ths

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment