josh/rails-behaviors — Issue #14: `app.assets` is `nil` during gem loading in Rails 3.1?
Author: mitio
Created: 2011-11-08 13:46:38+00:00
State: open

I just installed v0.1.0 and my Rails 3.1 app fails to boot because of this exception:

`undefined method `append_path' for nil:NilClass (NoMethodError)` (in `lib/rails/behaviors.rb:18`)

I have no idea why app.assets is `nil` in this case. If I omit the `rails-behaviors` gem from the `Gemfile` and then boot (still in development mode), then `Rails.application.assets` is not `nil` (it's a `Sprockets::Environment` as expected) and responds to `append_path`.

Here is the full backtrace:

```
/Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0/lib/active_support/whiny_nil.rb:48:in `method_missing': undefined method `append_path' for nil:NilClass (NoMethodError)
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rails-behaviors-0.1.0/lib/rails/behaviors.rb:18:in `block in '
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:25:in `run'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:50:in `block in run_initializers'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:49:in `each'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:49:in `run_initializers'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/application.rb:92:in `initialize!'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/dimitardimitrov/Projects/web/myapp/config/environment.rb:5:in `'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `block in load_dependency'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/application.rb:78:in `require_environment!'
from /Users/dimitardimitrov/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:39:in `'
from script/rails:6:in `require'
from script/rails:6:in `

'
```

If you need more info, I'm available.