Pregunta

I'm on Ruby 1.9.3 and Rails 3.0.11. I recently installed Draper(0.12.0) gem, but I'm unable to run its generators. I get the following error when I try to run the generator on the Post model :-

rails generate decorator Post
/home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/whiny_nil.rb:48:in `method_missing': undefined method `config' for nil:NilClass (NoMethodError)
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/draper-0.12.0/lib/draper/railtie.rb:6:in `block in <class:Railtie>'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/railtie.rb:189:in `call'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/railtie.rb:189:in `each'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/railtie.rb:189:in `load_generators'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/application.rb:147:in `block in load_generators'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/application/railties.rb:11:in `each'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/application/railties.rb:11:in `all'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/application.rb:147:in `load_generators'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/generators.rb:319:in `load_generators_from_railties!'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/generators.rb:278:in `lookup'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/generators.rb:141:in `find_by_namespace'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/generators.rb:161:in `invoke'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/commands/generate.rb:10:in `<top (required)>'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:239:in `require'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:239:in `block in require'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:225:in `block in load_dependency'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:593:in `new_constants_in'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:239:in `require'
    from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/commands.rb:17:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Any inputs, on how can I debug this would be really helpful.

Thank you.

¿Fue útil?

Solución

The Problem is this section in v0.12.0 (the one you are using) https://github.com/drapergem/draper/blob/v0.12.0/lib/draper/railtie.rb#L5-L8

When I look at the master branch they changed to code to look like: https://github.com/drapergem/draper/blob/master/lib/draper/railtie.rb#L5-L10

You should upgrade your draper gem to the latest release and see if the error still occurs.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top