表單提交時,它告訴我它已成功創建,但沒有顯示任何提交的數據。數據庫是空的。它顯示「null」值,在我應該能夠編輯數據的實際屏幕上顯示相同的值。下面是截圖不保存,沒有錯誤信息
更新:我認爲問題是,它使一個GET請求,但我不知道如何解決它。這裏是我的服務器的截屏做一個GET當我點擊提交
這裏的設置
在results_controller.rb的指標作用,我有
def index
@results = Result.all
@blob = Sex.new //[email protected] = Sex.new is the one I'm focussing on...
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @results }
end
end
在views/results/index中,我有表格
<`%= form_for(@blob) do |f| %>`
<div class="field">
<b>1. solicitor exam was fixed?:</b><br/>
<%= f.label(:solicitorcurve, "it was cooked") %>
<%= f.radio_button(:solicitorcurve, "t") %> </br>
</div>
<div class="field">
<%= f.label(:solicitorcurve, "no it was ok") %>
<%= f.radio_button(:solicitorcurve, "f") %>
</div>
<div class="field">
<%= f.label(:draftingteach, "i give the teaching a grade of _ on a scale of 1 to 6") %>
<%= f.select:draftingteach, 1..6 %> </br>
</div>
在sexes_controller.rb的創造作用,我有
def create
@sex = Sex.new(params[:blob])
respond_to do |format|
if @sex.save
format.html { redirect_to(@sex, :notice => 'Sex was successfully created.') }
format.xml { render :xml => @sex, :status => :created, :location => @sex }
else
format.html { render :action => "new" }
format.xml { render :xml => @sex.errors, :status => :unprocessable_entity }
end
end
end
在模型/ sex.rb,有什麼...
class Sex < ActiveRecord::Base
end
這是一組數據庫的後續處理
你在模型中使用attr_protected/accessible的機會有多大? –
該模型完全空白。那是問題嗎? - 類性別
Leahcim