イベント レコード用の新しい EventPlace を作成しようとしています。私はイベントをaccepts_nested_attributes_for :event_placesに設定し、私のビューには次のコードがあります:
<div id="add_venue_form" style="border:2px solid black; padding: 5px;">
<% form_for @event, :html => {:name => "form2"} do |f| -%>
<% f.fields_for @event_place do |v| -%>
<%= v.text_field :place_id %>
<% end -%>
<a class="button" style="margin-left:10px;margin-top:4px;" href="javascript:document.form2.submit();" onclick="this.blur();"><span>Save</span></a>
<% end -%>
フィールドに ID 番号を追加して保存ボタンをクリックすると、次のエラーが表示されます。
Processing EventController#update (for 127.0.0.1 at 2012-05-24 15:43:39) [PUT]
Parameters: {"id"=>"48404", "action"=>"update", "controller"=>"event",
"_method"=>"put", "event"=>{"event_place"=>{"place_id"=>"3"}}}
SQL (0.1ms) SET NAMES UTF8
Redirected to http://localhost:3001/event/list
Filter chain halted as [#<Proc:0x00000001094746e0@/Users/anthonylassiter/.rbenv/versions/ree-1.8.7 2012.02/lib/ruby/gems/1.8/gems/actionpack-2.3.10/lib/action_controller/verification.rb:82>] rendered_or_redirected.
Completed in 8ms (DB: 0) | 302 Found [http://localhost/events/48404]
私の更新方法
def update
@event = Event.find(params[:id])
if @event.update_attributes(params[:event])
redirect_to index
end
end
パラメータが正しいようです。私のevent_controllerで更新メソッドにヒットすることさえないようですが、代わりにいくつかの内部エラーを引き起こし、存在しない/ listにリダイレクトしようとしていますが、更新が機能していればそれは必要ありません.