1
更新:我是笨蛋。分發類是子類,並且這些類正在驗證狀態字段。當我的模型中的字段沒有驗證時驗證失敗
如果在這一點上我並不是很明顯,那麼我可能就不會這麼說了。 我試圖從我創建的表單中堅持對數據庫中的表進行一些更改。問題是,當我點擊提交按鈕,我得到這個:
Validation failed: Status is not included in the list
什麼,我不(?從整體錯誤信息預留 - 什麼列表)明白的是,狀態並不在驗證了我型號:
validates_presence_of :resume
validates_presence_of :matching_profile
validates_uniqueness_of :matching_profile_id, :scope => :owner_id
validates_numericality_of :price, :greater_than => 0, :allow_blank => true
沒有關於我可以看到的狀態。
更新:
所有的協會在我的模型:
belongs_to的:matching_profile,:counter_cache =>真 belongs_to的:恢復
更新:
問題似乎實際上是在我的控制器中:
def update_multiple
@distributions = Distribution.find(params[:distribution_ids])
@distributions.each do |distribution|
distribution.update_attributes!(params[:distro].reject { |k,v| v.blank? }) #raising an exception
end
flash[:notice] = "Updated Distribution Workflow"
redirect_to admin_distributions_workflows_path
end
您是否在模型中定義了'attr_accessible'? – maprihoda 2011-12-19 21:36:27
我不知道。請解釋。 – Ramy 2011-12-19 21:37:26
如果你1 /已經定義了attr_accessible,並且2 /沒有包含:可訪問屬性中的狀態和3 /正在你的代碼中的某處進行批量分配,那麼你會得到這個錯誤 – maprihoda 2011-12-19 21:42:11