错误:
undefined method `attribute_methods_generated?' for nil:NilClass
代码很简单,允许某人注册。在控制器中创建@tutor对象。每当我删除form_for时,页面加载正常,但似乎没有别的东西可以解决它。
代码:
<% form_for(@tutor) do |f| %>
<table class="form_table" id="home_form">
<tr>
<td>First Name:</td>
<td class="form">
<%= f.text_field :fname, :class => 'form', :size => 30 %>
</td>
</tr>
<tr>
<td>Last Name:</td>
<td class="form">
<%= f.text_field :lname, :class => 'form', :size => 30 %>
</td>
</tr>
<tr>
<td>Email:</td>
<td class="form">
<%= f.text_field :email, :class => 'form', :size => 30 %>
</td>
</tr>
<tr>
<td>Password:</td>
<td class="form">
<%= f.password_field :password, :class => 'form', :size => 20 %>
</td>
</tr>
]
<td> </td>
<td>
<div align="left">
<%= f.hidden_field :branch_id, :value => @branch.id.to_s %>
<%= f.submit 'Submit', :class => 'submit', :style => 'margin-left:3px;' %>
</div>
</td>
</tr>
</table>
<% end %>
这是stacktrace:
activesupport (3.0.10) lib/active_support/whiny_nil.rb:48:in `method_missing'
activerecord (3.0.10) lib/active_record/attribute_methods.rb:51:in `respond_to?'
actionpack (3.0.10) lib/action_view/helpers/form_helper.rb:329:in `apply_form_for_options!'
actionpack (3.0.10) lib/action_view/helpers/form_helper.rb:313:in `form_for'
app/views/tutors/register.html.erb:3:in `_app_views_tutors_register_html_erb__142383781_2257394860_0'
actionpack (3.0.10) lib/action_view/template.rb:135:in `send'
actionpack (3.0.10) lib/action_view/template.rb:135:in `render'
activesupport (3.0.10) lib/active_support/notifications.rb:54:in `instrument'
actionpack (3.0.10) lib/action_view/template.rb:127:in `render'
actionpack (3.0.10) lib/action_view/render/rendering.rb:59:in `_render_template'
activesupport (3.0.10) lib/active_support/notifications.rb:52:in `instrument'
activesupport (3.0.10) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.10) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.10) lib/action_view/render/rendering.rb:56:in `_render_template'
actionpack (3.0.10) lib/action_view/render/rendering.rb:26:in `render'
actionpack (3.0.10) lib/abstract_controller/rendering.rb:115:in `_render_template'
actionpack (3.0.10) lib/abstract_controller/rendering.rb:109:in `render_to_body'
actionpack (3.0.10) lib/action_controller/metal/renderers.rb:47:in `render_to_body'
actionpack (3.0.10) lib/action_controller/metal/compatibility.rb:55:in `render_to_body'
actionpack (3.0.10) lib/abstract_controller/rendering.rb:102:in `render_to_string'
以下是导师班:
class Tutor < ActiveRecord::Base
belongs_to :branch
end
答案 0 :(得分:0)
想出来。我把“class”作为表中的一行。
感谢您的帮助!