Ruby on rails 3 验证嵌套属性

Ruby on rails 3 验证嵌套属性,ruby-on-rails-3,Ruby On Rails 3,为什么不调用资源分配中的验证 class Employee < ActiveRecord::Base has_many :resource_allocations accepts_nested_attributes_for :resource_allocations validates_associated :resource_allocations end class ResourceAllocation < Ac

为什么不调用
资源分配中的验证

class Employee < ActiveRecord::Base 
         has_many :resource_allocations
         accepts_nested_attributes_for :resource_allocations
         validates_associated :resource_allocations
    end


class ResourceAllocation < ActiveRecord::Base
  belongs_to :employee

  validate :location_id, :presence => true
  validate :department_id, :presence => true
  validate :period_from, :presence => true
  validate :period_to, :presence => true
  validate :allocation, :presence => true, :numericality => true
end
class Employeetrue
验证:部门id,:状态=>true
验证:期间\从,:存在=>true
验证:周期_到,:存在=>true
验证:分配,:存在=>true,:数值=>true
终止