Ошибка Rails: неопределенный метод attribute_methods_generated? для ноля: NilClass - PullRequest
1 голос
/ 30 декабря 2011

Ошибка:

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>&nbsp;</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 %>

Вот трассировка стека:

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

1 Ответ

0 голосов
/ 03 января 2012

Разобрался.У меня был «класс» в качестве одной из строк в таблице.

Спасибо за помощь, хотя!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...