Has "def validate" been taken out in Rails 3.1? I'm on Rails 3.1 pre and it doesn't seem to be working
class Category < ActiveRecord::Base
  validates_presence_of :title
  private 
  def validate
    errors.add(:description, "is too short") if (description.size < 200)
  end 
end
The "title" validation works but the "description" validation doesn't.
Does something like this work for you?
class Category < ActiveRecord::Base
  validates_presence_of :title
  validate :description_length
  def description_length
    errors.add(:description, "is too short") if (description.size < 200)
  end 
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With