0

我的 nifty_scaffold 有一个错误...由于某种原因(没有更改任何标准代码,检查了 routes.rb,...),创建新的营养不起作用。

谁能解释我如何以及解决方案是什么?

我想我已经包含了所有必要的代码......

详细的错误是:未定义的方法`generated_methods' for nil:NilClass

路线包含:

map.resources :nutritions

视图:新

<% title "New Nutrition" %>
<%= render :partial => 'form' %>
<p><%= link_to "Back to List", nutritions_path %></p>

查看:_form

<% form_for @nutrition do |f| %>
  <%= f.error_messages %>
  <p>
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </p>
  <p>
    <%= f.label :description %><br />
    <%= f.text_area :description %>
  </p>
  <p>
    <%= f.label :ammount %><br />
    <%= f.text_field :ammount %>
  </p>
  <p>
    <%= f.label :unit %><br />
    <%= f.text_field :unit %>
  </p>
  <p>
    <%= f.label :kcal %><br />
    <%= f.text_field :kcal %>
  </p>
  <p>
    <%= f.label :protein %><br />
    <%= f.text_field :protein %>
  </p>
  <p>
    <%= f.label :carb %><br />
    <%= f.text_field :carb %>
  </p>
  <p>
    <%= f.label :fat %><br />
    <%= f.text_field :fat %>
  </p>
  <p>
    <%= f.label :type %><br />
    <%= f.text_field :type %>
  </p>
  <p>
    <%= f.label :class %><br />
    <%= f.text_field :class %>
  </p>
  <p><%= f.submit "Submit" %></p>
<% end %>

还有我的营养控制器

  def new
    @nutrition = Nutrition.new
    #raise @progress.inspect (debug porpose, didn't help)
  end

这是完整的跟踪

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 :在render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable_partial.rb:20:in渲染' 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:inrender' 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:inms' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in渲染'C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1326:indefault_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:inprocess' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:386:in调用'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:incall' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in调用'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:incall' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in进程'C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:159:in each'C: process_client' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:in/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 :在run' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in初始化'C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:在new' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in运行'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:inrequire' script/server:3-e:2:in加载'-e:2

4

1 回答 1

2

看起来不错,只是将属性命名为“类”似乎不是一个好主意,它通常是保留字......

于 2010-03-02T11:28:00.953 回答