我正在使用rails 3.2.6。我在我的模型文件中添加了这个:
has_one :avatar, :as => :imageable, :dependent => :destroy
validates_presence_of :avatar, :message => "can't be empty"
但如果字段留空,我没有收到任何错误消息。我只在页面顶部显示Please review the problems below:
。任何人都可以提出任何建议吗?
has_one :avatar, :as => :imageable, :dependent => :destroy
has_many :attachments, :as => :attachable, :dependent => :destroy
accepts_nested_attributes_for :avatar, :reject_if => :all_blank
实际上如何在嵌套属性中给出错误信息?