codegram/spinach-rails — Issue #2: Conflict with Devise routes
Author: latentflip
Created: 2011-10-26 11:51:39+00:00
State: open

This isn't going to be the best bug report, but I wanted to raise this in case anyone's come across it/comes across it in the future. I'll try and expand on it as I understand it better.

I am using Devise in my Rails 3.1 app, and when using the spinach-rails gem my app won't start (I've appended the traceback).

I _think_ what is happening is:

* The spinach-rails railtie extension is loading all the routes from (https://github.com/codegram/spinach-rails/blob/master/lib/spinach-rails/railtie.rb)
* This in turn is triggering devise to set up all of it's magic login etc routes
* But it is doing it _before_ devise has been configured in my `config/initializers/devise.rb` initializer.
* This crashes startup.

Unfortunately I am not yet acquainted enough with the whole railties boot sequence to figure out a fix and to test it, but I suspect we need to either trigger the devise initializing earlier, or the spinach rails initializing later. Certainly commenting out the `initializer "add routes"` block means that everything starts up fine (although presumably I lose the named routes support)

Any thoughts?

### Here's the traceback I get

/Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:1082:in `method_missing': undefined method `devise' for # (NoMethodError)
from /Users/latentflip/.../FloatApp/app/models/user.rb:4:in `'
from /Users/latentflip/.../FloatApp/app/models/user.rb:1:in `'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:348:in `require_or_load'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:489:in `load_missing_constant'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:181:in `block in const_missing'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:179:in `each'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:179:in `const_missing'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:124:in `block in constantize'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:123:in `each'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:123:in `constantize'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:528:in `block in initialize'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:550:in `yield'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:550:in `default'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:550:in `[]'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:595:in `constantize'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/devise-1.4.9/lib/devise.rb:259:in `get'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/devise-1.4.9/lib/devise/mapping.rb:103:in `to'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/devise-1.4.9/lib/devise/mapping.rb:98:in `modules'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/devise-1.4.9/lib/devise/mapping.rb:115:in `routes'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/devise-1.4.9/lib/devise/mapping.rb:84:in `initialize'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/devise-1.4.9/lib/devise.rb:289:in `new'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/devise-1.4.9/lib/devise.rb:289:in `add_mapping'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/devise-1.4.9/lib/devise/rails/routes.rb:190:in `block in devise_for'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/devise-1.4.9/lib/devise/rails/routes.rb:189:in `each'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/devise-1.4.9/lib/devise/rails/routes.rb:189:in `devise_for'
from /Users/latentflip/.../FloatApp/config/routes.rb:45:in `block in '
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:257:in `instance_exec'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:257:in `eval_block'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:234:in `draw'
from /Users/latentflip/.../FloatApp/config/routes.rb:1:in `'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `block in load'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/routes_reloader.rb:29:in `block in load_paths'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/routes_reloader.rb:29:in `each'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/routes_reloader.rb:29:in `load_paths'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/routes_reloader.rb:13:in `reload!'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application.rb:83:in `reload_routes!'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/devise-1.4.9/lib/devise/rails.rb:14:in `block in '
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/lazy_load_hooks.rb:34:in `call'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/finisher.rb:50:in `block in '
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:25:in `run'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:50:in `block in run_initializers'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:49:in `each'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:49:in `run_initializers'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application.rb:92:in `initialize!'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/latentflip/.../FloatApp/config/environment.rb:5:in `'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `block in load_dependency'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application.rb:78:in `require_environment!'
from /Users/latentflip/.../FloatApp/spinach-rails/ruby/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:39:in `'
from script/rails:6:in `require'