Kristian Mandrup
2010-Jan-28 23:52 UTC
Discovered potential rails 3 error: lib/rails/generators.rb:269 - undefined method `application'' for Rails:Module
When I run the generator as script/generate it works, but when I use my executable calling the same controller it breaks. I have seen this kind of error in other instances where I was able to fix it inside the generator, but in this case the error seems to stem from a dependency on rails internals? 269 return if defined?(@generators_from_railties) || Rails.application.nil? I think that in this context for some reson Rails.application is not defined!? I have been installing this gem and running the executable nifty_controller defined within this gem http://github.com/kristianmandrup/very_nifty_generators --- kristian-mandrups-macbook-pro:r3_test kristianconsult$ script/generate nifty:controller cat create app/controllers/cats_controller.rb invoke erb create app/views/cat invoke test_unit create test/functional/cat_controller_test.rb error helper [not found] kristian-mandrups-macbook-pro:r3_test kristianconsult$ nifty_controller dog create app/controllers/dogs_controller.rb /opt/local/lib/ruby/gems/1.9.1/gems/railties-3.0.pre/lib/rails/ generators.rb:269:in `load_generators_from_railties!'': undefined method `application'' for Rails:Module (NoMethodError) from /opt/local/lib/ruby/gems/1.9.1/gems/railties-3.0.pre/lib/rails/ generators.rb:232:in `lookup'' from /opt/local/lib/ruby/gems/1.9.1/gems/railties-3.0.pre/lib/rails/ generators.rb:141:in `find_by_namespace'' from /opt/local/lib/ruby/gems/1.9.1/gems/railties-3.0.pre/lib/rails/ generators/base.rb:331:in `prepare_for_invocation'' from /opt/local/lib/ruby/gems/1.9.1/gems/railties-3.0.pre/lib/rails/ vendor/thor-0.12.3/lib/thor/group.rb:159:in `_invoke_from_option_template_engine'' from /opt/local/lib/ruby/gems/1.9.1/gems/railties-3.0.pre/lib/rails/ vendor/thor-0.12.3/lib/thor/task.rb:32:in `run'' from /opt/local/lib/ruby/gems/1.9.1/gems/railties-3.0.pre/lib/rails/ vendor/thor-0.12.3/lib/thor/invocation.rb:108:in `block in invoke'' from /opt/local/lib/ruby/gems/1.9.1/gems/railties-3.0.pre/lib/rails/ vendor/thor-0.12.3/lib/thor/invocation.rb:117:in `each'' from /opt/local/lib/ruby/gems/1.9.1/gems/railties-3.0.pre/lib/rails/ vendor/thor-0.12.3/lib/thor/invocation.rb:117:in `map'' from /opt/local/lib/ruby/gems/1.9.1/gems/railties-3.0.pre/lib/rails/ vendor/thor-0.12.3/lib/thor/invocation.rb:117:in `invoke'' from /opt/local/lib/ruby/gems/1.9.1/gems/railties-3.0.pre/lib/rails/ vendor/thor-0.12.3/lib/thor/group.rb:35:in `block in start'' from /opt/local/lib/ruby/gems/1.9.1/gems/railties-3.0.pre/lib/rails/ vendor/thor-0.12.3/lib/thor/base.rb:354:in `start'' from /opt/local/lib/ruby/gems/1.9.1/gems/railties-3.0.pre/lib/rails/ vendor/thor-0.12.3/lib/thor/group.rb:28:in `start'' from /opt/local/lib/ruby/gems/1.9.1/gems/very_nifty_generators-0.1.2/ bin/nifty_controller:28:in `<top (required)>'' from /opt/local/bin/nifty_controller:19:in `load'' from /opt/local/bin/nifty_controller:19:in `<main>'' kristian-mandrups-macbook-pro:r3_test kristianconsult$ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Kristian Mandrup
2010-Jan-29 23:17 UTC
Re: Discovered potential rails 3 error: lib/rails/generators.rb:269 - undefined method `application'' for Rails:Module
The solution was to add require ''rails'' to my executable. But I still see it as an odd edge case and a bit of a "hack"... nifty_controller -- #!/user/local/bin/ruby ... require ''rails'' <<<< require ''rails/generators'' require ''generators/nifty/controller/controller_generator'' Nifty::Generators::ControllerGenerator.start -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.