驗證rails 3.2中創建的has_many對象的數量?驗證rails中創建的has_many對象的數量3.2
我需要一個自定義驗證關聯對象的「最大/最小」計數。 我有房產,有
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
非常感謝。我不知道這樣的存在。這很有用。 – 2013-05-08 09:25:48
** @ Semyon Perepelitsa **你能告訴我爲什麼會發生這種情況[鏈接](http://stackoverflow.com/questions/16413271/nester-attributes-for-has-many-are-not-shown-if - 表單驗證失敗?) – 2013-05-08 09:45:25
當然,我也回答了。我希望它有幫助。 – 2013-05-08 10:11:21