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

Already on GitHub? Sign in to your account

rails g devise user raises Rails 4 ActiveRecord::Model is not a class/module (TypeError) #2091

Closed
calebthompson opened this Issue Oct 5, 2012 · 2 comments

Comments

Projects
None yet
3 participants

On a fresh Rails 4 app, calling rails generate devise user causes the error below.

I tried adding pry into lib/devise/orm/active_record.rb before the line 3. When I typed ActiveRecord::Base, the type error was raised. When I exited pry, the generator completed successfully, so I'm thinking this is a problem related to Rails' autoload.

Adding

begin
  ActiveRecord::Base
rescue
end

before ActiveRecord::Base.extend Devise::Models did not resolve this, which I rather expected it to since it should have performed similarly to my pry session.

/related: #2062
/cc @sikachu

/Users/caleb/.rvm/gems/ruby-1.9.3-p194/gems/orm_adapter-0.4.0/lib/orm_adapter/adapters/active_record.rb:73:in `block in <top (required)>': ActiveRecord::Model is not a class/module (TypeError)
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/lazy_load_hooks.rb:44:in `each'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activerecord/lib/active_record/base.rb:328:in `<top (required)>'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activerecord/lib/active_record/model.rb:166:in `<module:ActiveRecord>'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activerecord/lib/active_record/model.rb:3:in `<top (required)>'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:227:in `require'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:227:in `block in require'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:212:in `load_dependency'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:227:in `require'
    from /Users/caleb/code/devise/lib/devise/orm/active_record.rb:1:in `<top (required)>'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:227:in `require'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:227:in `block in require'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:212:in `load_dependency'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:227:in `require'
    from /Users/caleb/code/thinkers/config/initializers/devise.rb:16:in `block in <top (required)>'
    from /Users/caleb/code/devise/lib/devise.rb:252:in `setup'
    from /Users/caleb/code/thinkers/config/initializers/devise.rb:3:in `<top (required)>'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:221:in `load'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:221:in `block in load'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:212:in `load_dependency'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:221:in `load'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/railties/lib/rails/engine.rb:604:in `block (2 levels) in <class:Engine>'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/railties/lib/rails/engine.rb:603:in `each'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/railties/lib/rails/engine.rb:603:in `block in <class:Engine>'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/railties/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/railties/lib/rails/initializable.rb:30:in `run'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/railties/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/caleb/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:150:in `block in tsort_each'
    from /Users/caleb/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
    from /Users/caleb/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:210:in `block (2 levels) in each_strongly_connected_component_from'
    from /Users/caleb/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:219:in `each_strongly_connected_component_from'
    from /Users/caleb/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:209:in `block in each_strongly_connected_component_from'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/railties/lib/rails/initializable.rb:44:in `each'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/railties/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /Users/caleb/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:203:in `each_strongly_connected_component_from'
    from /Users/caleb/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:182:in `block in each_strongly_connected_component'
    from /Users/caleb/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:180:in `each'
    from /Users/caleb/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:180:in `each_strongly_connected_component'
    from /Users/caleb/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:148:in `tsort_each'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/railties/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/railties/lib/rails/application.rb:185:in `initialize!'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/railties/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/caleb/code/thinkers/config/environment.rb:5:in `<top (required)>'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:227:in `require'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:227:in `block in require'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:212:in `load_dependency'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/activesupport/lib/active_support/dependencies.rb:227:in `require'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/railties/lib/rails/application.rb:159:in `require_environment!'
    from /Users/caleb/.rvm/gems/ruby-1.9.3-p194/bundler/gems/rails-2b83b07307c3/railties/lib/rails/commands.rb:23:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
Contributor

westonplatter commented Oct 26, 2012

You can solve this error by wrapping extend/include logic in an "included do" block.

Here's how I got it working.
https://github.com/westonplatter/orm_adapter/commit/da7465f6b803ee8d8d7d6348984777a76aa99c00

Any chance we can get a Rails4 branch for devise?

cc @ianwhite @josevalim

Owner

josevalim commented Oct 26, 2012

I believe this is a Rails bug. I have talked to Jon which recently changed it to go back to work just fine in Rails. Thanks everyone.

@josevalim josevalim closed this Oct 26, 2012

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