我認爲新形式無法從視圖中獲取值到控制器
<h1>Add Form 3C </h1>
<%= form_for([@basiccase, @form3c]) do |f| %>
<%= render 'shared/error_messages', :object => f.object %>
<div class="field">
<%= f.label :date_of_investigation %>
<%= f.date_select :date_of_investigation, {:include_blank => true, :default => nil} %>
</div>
<div class="actions">
<%= f.submit "Add Form" %>
</div>
<% end %>
我對新的控制器和創造是
def new
@title = "New Form 3C"
@basiccase = Basiccase.find_by_id(params[:basiccase_id])
@form3c = @basiccase.build_form3_c
end
def create
@basiccase = Basiccase.find_by_id(params[:basiccase_id])
@form3c = @basiccase.build_form3_c(params[:form3c])
if @form3c.save
flash[:success] = "Form created!"
redirect_to current_user
else
flash[:warning] ="Failed to create a Form"
render 'users/show'
end
end
我拿不到則params的值:form3c]到創建控制器中。當我試圖檢查puts params [:form3c]時,它顯示爲空白。可以任何幫助我,我錯了
你試過'PARAMS [:form3_c]'呢?看看你的development.log文件,當你提交表單時你應該看到實際的params散列的完整輸出。 – 2012-03-26 00:15:49