2012-05-24 2 views
1

이벤트 레코드에 대해 새 EventPlace를 만들려고합니다. 나는 이벤트 accepts_nested_attributes_for을 설정 한 : event_places 내보기에 다음 코드를 :fields_ 필터 체인 중지 오류 발생

<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 번호를 추가하고 저장 버튼을 클릭

, 그것은 나에게 오류를 제공합니다

params 객체를 파라미터는 고전처럼
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:[email protected]/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 

같습니다 rect. 내 event_controller에서 내 업데이트 메소드를 치는 것조차 보이지 않는 대신 내부 오류가 발생하고/list에 존재하지 않는 리디렉션을 시도하지만 Update가 작동하는 경우에는 필요하지 않습니다.

답변

1

어딘가에서 :event_places를 사용 PARAMS 당신에있을 필요가 R, 정확하지 않은 (또는 그 슈퍼 클래스 중 하나) 당신은에 verify를 사용하는 어떤 요청을 할 수 있는지 (또는 당신이 사용하고있는 플러그인이 검증이라고 부를 수 있음) 제한하십시오. 로깅 된 요청이 이러한 확인 단계 중 하나에서 실패하여 레일스가 대신 리디렉션했습니다.

+0

그게 전부였습니다! 고맙습니다. 이것은 다른 사람의 코드이므로 그들이 한 일을 발견하고 있습니다. 그것은 확인 중이었습니다 : 게시물, 그리고 내가 사용하고있는 : 레코드를 업데이 트하다. 다시 한번 감사드립니다. – alassiter

1

에 Params는 event_places_attributes이 ... @event.event_places.build을 시도하고 컨트롤러에 fields_for

+0

그게 더 가까워졌지만 params에서이 문제가 발생합니다. "event"=> { "event_places_attributes"=> { "place_id"=> "3"}}} 여기서 0 와라. 나는 일련의 속성이 만들어 졌다고 생각하지만 정확한 오류가 발생했습니다. – alassiter