2011-06-21 40 views

回答

1

this answer你應該能夠做到:

validate :has_at_least_two_potatoes? 

def has_at_least_two_potatoes? 
    errors.add_to_base "Model must have at least 2 potatoes" if self.potatoes.size < 2 
end 
3

Rails 3的?試試:

validates :b, :length => { :minimum => 2 } 
相關問題