aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/test/fixtures/project.rb
blob: 53de6666019fe90b5347cc68e95705c644da4a45 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# used to test validations
class Project < ActiveResource::Base
  self.site = "http://37s.sunrise.i:3000"
  schema do
    string  :email
    string  :name
  end

  validates :name, :presence => true
  validates :description, :presence => false, :length => {:maximum => 10}
  validate :description_greater_than_three_letters

  # to test the validate *callback* works
  def description_greater_than_three_letters
    errors.add :description, 'must be greater than three letters long' if description.length < 3 unless description.blank?
  end
end