2009-10-02 6 views
2

index.erb.html 파일에 양식이 있습니다. (업로드 컨트롤러). 내가 localhost를 호출 할 때 은 : 3000/업로드 내가 두 번째 선택 필드를 업데이트하는 AJAX를 사용하기 때문에/오류가, 내가 렌더링 기능을 가지고, 그래서 인수의 잘못된 번호 (1 0) 오류잘못된 인수 개수 (1에 대해 0)

<% form_for :picture, :html => { :multipart => true } do |form| %> 
<p> 
    <label for="picture_first_name">First name::</label> 
    <%= form.text_field :first_name, :size => 20 %> 
</p> 
<p> 
    <label for="picture_last_name">Last name:</label> 
    <%= form.text_field :last_name, :size => 20 %> 
</p> 
<p> 
    <label for="picture_city">City:</label> 
    <%= form.select :city, Picture::CITIES, {}, :onchange => remote_function(:url => {:action => "update_universities"}, :with => "'picture[city]='+value") %> 
</p> 
<p> 
    <%= render :partial => 'universities' %> 
</p> 
<p> 
    <label for="picture_picture">Photo::</label> 
    <%= form.file_field :picture, :size => 20 %> 
</p> 
<%= submit_tag "Upload" %> 
<% end %> 

을 appeares.

<label for="picture_university">University:</label> 
    <%= form.select :university, [] %> 

내 응용 프로그램의 문제점은 무엇입니까? 저를 고치는 것을 도와주세요! 업로드 # 지수

오류 ArgumentError

라인 # 2가 제기 응용 프로그램 /보기/업로드/_universities.html.erb 보기 :

인수 잘못된 번호 (0 1)을

추출 소스 (주위 선 # 2)

1 대학 : 2 <% = form.select : 보편 의 sity, [] %>

템플릿 포함의 추적 : 응용 프로그램 /보기/업로드/index.html.erb

RAILS_ROOT :/홈/user_admin/MyApp를 응용 프로그램 추적 | 프레임 워크 추적 | 전체 추적

form' /home/user_admin/myapp/app/views/upload/_universities.html.erb:2:in _run_erb_app47views47upload47_universities46html46erb_locals_object_universities ' /home/user_admin/myapp/app/views/upload/index.html /home/user_admin/myapp/app/views/upload/_universities.html.erb:2:in .erb : 15 : _run_erb_app47views47upload47index46html46erb' /home/user_admin/myapp/app/views/upload/index.html.erb:1:in _run_erb_app47views47upload47index46html46erb '

+1

내가보기에 'form'변수는'university' 뷰에서 알 수 없지만 다른 오류가 발생합니다. 자세한 오류 추적을 제공해야합니다. – Koraktor

+0

Koraktor, 제발 도와주세요. 방금 ​​전체 오류 추적을 추가했습니다. – Anton

답변

2

에 당신은 당신의 부분, 그래서를 통해 form 변수를 전달해야합니다

<%= render :partial => 'universities', :locals => {:form => form } %> 

이렇게하면 양식 객체를 부분적으로 사용할 수있게해야합니다.

+0

Lolindrath, 정말 고맙습니다. 나는 지금 행복해. 하지만 왜 내가 그렇게해야하는지 이해할 수 없습니다. RAILS 프레임 워크는 매우 지적되고 어렵습니다. – Anton

+1

이 이유는 변수 범위를 변경하는 다른 루비 파일로 이동하기 때문입니다. Rails에서 처리해야하는 몇 가지 기발한 일이 있지만 일반적으로 레일스가 개발할 수있는 전단 속도는 엄청납니다. – Lolindrath

관련 문제