Indhold 모델에 여러 개의 Indhold를 작성하고 싶습니다. 하지만 제출할 때 1 Indhold 매개 변수 만 가져오고 여러 체크 박스를 선택하더라도 1 개의 불만을 표시합니다. 새로운 인디 드 너비 확인란을 선택하여 확인하십시오. 내 indhold 양식 :레일 여러 확인란을 사용하여 객체를 작성하는 방법
<%= form_tag({:action => 'create'}, {:multipart => true}) %>
<% for indhold in Indhold.find(:all) %>
<%= check_box_tag("indholds[navn]", indhold.navn) %>
<%= indhold.navn %><br />
<% end %>
</div>
<div class="actions">
<%= submit_tag("Submit") %>
</div>
내 indhold 컨트롤러 :
def new
@indhold = Indhold.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @indhold }
end
end
def create
@indhold = Indhold.new(params[:indhold])
respond_to do |format|
if @indhold.save
format.html { redirect_to(@indhold, :notice => 'Indhold was successfully created.') }
format.xml { render :xml => @indhold, :status => :created, :location => @indhold }
else
format.html { render :action => "new" }
format.xml { render :xml => @indhold.errors, :status => :unprocessable_entity }
end
end
안부, 레일은 체크 박스에서 indholds [navn] []에
기존의 Indholds에서 children navn 값을 포함하는 Indhold를 만들려고했지만 Indhold.navn이 has_many가 아닌 것처럼 보입니다 - 정확합니까? Indhold 모델에 대한 코드를 추가 할 수 있습니까? –
나는 아이들이 들어있는 Indhold를 만들려고하지 않고있다. indhold 모델에서 많은 Indholds 너비 확인란을 만들려고합니다. –