Rails 2.2のscaffoldでRuntimeError

再現方法

1. 適当なモデル(いつもの'Person')と、対応するテーブル(いつもの'People')を生成 (generate model person ... )
2. 静的なscaffold形成 (generate scaffold person name:string, address:string, ...)
3. 生成されたperson_controller内のnewメソッドの先頭にブレークポイント設定
4. RubyMineからデバッグセッション開始
5. newメソッド起動 ( http://localhost:3000/addressbook/people/new )
6. ブレークポイントで止まるのを確認した後にF9等でコンティニュ
7. ビュー(new.html.erb)に制御が移った直後にRuntimeErrorが発生

  • エラーが発生した際のビュー
RuntimeError in People#new 
Showing app/views/people/new.html.erb where line #3 raised: 

Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id

Extracted source (around line #3): 

1: <h1>New person</h1>
2: 
3: <% form_for(@person) do |f| %>
4:   <%= f.error_messages %>
5: 
6:   <p>

RAILS_ROOT: E:/www/addressbook

Application Trace | Framework Trace | Full Trace 
vendor/rails/actionpack/lib/action_controller/record_identifier.rb:76:in `dom_id'
vendor/rails/actionpack/lib/action_view/helpers/record_identification_helper.rb:16:in `dom_id'
vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:264:in `apply_form_for_options!'
vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:248:in `form_for'
app/views/people/new.html.erb:3
app/controllers/people_controller.rb:29:in `new'
-e:1:in `load'
-e:1

ブレークポイントで止めたことによってモデルが壊れたらしいが、詳細は不明。
これもフィードバック済み。