0
나는 기존 레코드의 여러 형태의 한 페이지가있는 경우 :한 페이지에 여러 양식을 처리하는 방법은 무엇입니까?
selections_controller :
index.html.haml 다음
- for selection in @selections
- form_for selection, :method => :put do |form|
= form.collection_select :user_id, @current_account.users, :id, :full_name
과이 제출하기로 업데이트 행동. rb
def update
selection = Selection.find(params[:id])
if selection.update_attributes(params[:selection])
flash[:notice] = "Save!"
redirect_to selections_path
else
flash[:errors] = "Errors"
render :index
end
end
어떻게하면 좋을까요? 같은 페이지에 여러 양식이있는 경우 오류 메시지가 표시됩니다. 양식 중 하나에 대한
selection.errors.on(:user_id)
: 즉 내가 사용하려면?
나는이 오류가 무엇입니까 : @ # <선택은 : 0x0000010276a000>은 '인스턴스 오류에 해당 무엇을 줄 변수 이름 – Cameron
으로 사용할 수 없습니다. – EmFi
error_messages_for @selection을 사용하여 문제를 해결했다고 생각합니다. – Cameron