NoMethodError in Nutritions#new - undefined method '' for nil:NilClass?

It looks fine, just naming an attribute as "class" does not seem to be a good idea, it's usually pretty much reserved word...

Up vote 0 down vote favorite share g+ share fb share tw.

I have an error in my nifty_scaffold... For some reason (didn't change any standard code, checked the routes. Rb, ...), creating a new nutrition won't work. Could anyone explain me how and what the solution is?

I think I have included all necessairy code... The error in detail is: undefined method `generated_methods' for nil:NilClass Route contains: map. Resources :nutritions View: New 'form' %> View: _form And my nutrition controller def new @nutrition = Nutrition. New #raise @progress.

Inspect (debug porpose, didn't help) end And this is the full Trace C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/whiny_nil. Rb:52:in method_missing' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods. Rb:352:inrespond_to?

' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/array/wrapper. Rb:14:in wrap' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/active_record_helper. Rb:174:inerror_messages_for' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/form_helper.

Rb:1012:in error_messages' D:/Workspace/Aptana/UltimateJournal/app/views/nutritions/_form.html. Erb:3:in_run_erb_app47views47nutritions47_form46html46erb_locals_form_object' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/form_helper. Rb:499:in fields_for' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/form_helper.

Rb:282:inform_for' D:/Workspace/Aptana/UltimateJournal/app/views/nutritions/_form.html. Erb:2:in _run_erb_app47views47nutritions47_form46html46erb_locals_form_object' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable. Rb:34:insend' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.

Rb:34:in render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base. Rb:306:inwith_template' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable. Rb:30:in render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable_partial.

Rb:20:inrender' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking. Rb:26:in benchmark' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark. Rb:17:inms' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.

Rb:10:in realtime' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark. Rb:17:inms' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking. Rb:26:in benchmark' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable_partial.

Rb:19:inrender' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/template. Rb:205:in render_template' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable_partial. Rb:44:inrender_partial' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/partials.

Rb:184:in render_partial' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base. Rb:267:inrender' D:/Workspace/Aptana/UltimateJournal/app/views/nutritions/new.html. Erb:3:in _run_erb_app47views47nutritions47new46html46erb' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.

Rb:34:insend' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable. Rb:34:in render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base. Rb:306:inwith_template' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.

Rb:30:in render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/template. Rb:205:inrender_template' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base. Rb:265:in render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.

Rb:348:in_render_with_layout' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base. Rb:262:in render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base. Rb:1250:inrender_for_file' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.

Rb:945:in render_without_benchmark' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking. Rb:51:inrender' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark. Rb:17:in ms' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.

Rb:10:inrealtime' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark. Rb:17:in ms' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking. Rb:51:inrender' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.

Rb:1326:in default_render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base. Rb:1332:inperform_action_without_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters. Rb:617:in call_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.

Rb:610:inperform_action_without_benchmark' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking. Rb:68:in perform_action_without_rescue' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark. Rb:17:inms' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.

Rb:10:in realtime' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark. Rb:17:inms' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking. Rb:68:in perform_action_without_rescue' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/rescue.

Rb:160:inperform_action_without_flash' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/flash. Rb:146:in perform_action' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base. Rb:532:insend' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.

Rb:532:in process_without_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters. Rb:606:inprocess' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base. Rb:391:in process' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.

Rb:386:incall' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set. Rb:437:in call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher. Rb:87:indispatch' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.

Rb:121:in _call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher. Rb:130:inbuild_middleware_stack' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache. Rb:29:in call' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.

Rb:29:incall' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/query_cache. Rb:34:in cache' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache. Rb:9:incache' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.

Rb:28:in call' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool. Rb:361:incall' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion. Rb:25:in call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.

Rb:9:incall' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride. Rb:24:in call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/params_parser. Rb:15:incall' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/cookie_store.

Rb:93:in call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/failsafe. Rb:26:incall' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock. Rb:11:in call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.

Rb:11:insynchronize' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock. Rb:11:in call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher. Rb:114:incall' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/reloader.

Rb:34:in run' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher. Rb:108:incall' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/static. Rb:31:in call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.

Rb:46:incall' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap. Rb:40:in each' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap. Rb:40:incall' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.

Rb:17:in call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length. Rb:13:incall' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/chunked. Rb:15:in call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.

Rb:64:inprocess' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel. Rb:159:in process_client' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel. Rb:158:ineach' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.

Rb:158:in process_client' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel. Rb:285:inrun' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel. Rb:285:in initialize' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.

Rb:285:innew' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel. Rb:285:in run' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel. Rb:268:ininitialize' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.

Rb:268:in new' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel. Rb:268:inrun' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel. Rb:34:in run' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.

Rb:111 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require. Rb:31:ingem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require. Rb:31:in require' script/server:3-e:2:inload'-e:2 ruby-on-rails scaffolding link|improve this question edited Mar 2 '10 at 11:17 asked Mar 2 '10 at 4:26NicoJuicy532418 80% accept rate.

(including the files and lines number of the failure). – Damien MATHIEU Mar 2 '10 at 8:53.

You are right, I added migrations to the model (class, type => nutri_class, nutri_type). Do I need to change anything else in my nifty_scaffold? Eg.

Change the view, controller, ...? Because, my nutri_class, nutri_type in the view of :action => "new", automaticly have the text "Nutrition" in them. How come? – NicoJuicy Mar 2 '10 at 11:52 you need to change names of fields in your views, which were generated by scaffold, default values would be probably set in view – deric Mar 11 '10 at 9:11.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions