验证 rails 3.2 中创建的 has_many 对象的数量?
我需要对关联对象的“最大/最小”计数进行自定义验证。我有房地产,有
has_many :realty_images, :dependent => :destroy
accepts_nested_attributes_for :realty_images
和 realty_image:
class RealtyImage < ActiveRecord::Base
attr_accessible :avatar, :image, :realty_id
belongs_to :realty
#here a suppose I need to put some kind of custom validation
mount_uploader :image, ImageUploader
end