0
阅读this thread后,覆盖在验证belongs_to的对象与它的ID之间的区别,我有一个相关的问题:冗余验证?
我有以下验证
validates_presence_of :batch_id
validates_numericality_of :batch_id, :only_integer => true, :greater_than => 0
是第二额外的检查验证: batch_id是否值得,或者是多余的?
从理论上讲,Rails知道batch_id的语义,并且可以比它刚才存在的更彻底地验证它。例如,我不想为batch_id获取值-1。
谢谢。