如果我的模型中没有对该字段进行验证,则验证失败

时间:2011-12-19 21:27:26

标签: ruby-on-rails ruby-on-rails-3 forms validation model

更新:我是个笨蛋。分发类是子类,THOSE类正在验证状态字段。

如果在这一点上不明显我对铁路来说是一个很好的东西,它甚至可能都不值得说。 我试图从我创建的表单中继续对DB中的表进行一些更改。问题是,当我点击提交按钮时,我得到了这个:

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:resume

更新

问题似乎实际上在我的控制器中:

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

1 个答案:

答案 0 :(得分:2)

状态字段正在子类中验证。