Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c2f90d6530
Fetching contributors…

Cannot retrieve contributors at this time

26 lines (20 sloc) 0.736 kb
# used to test validations
class Project < ActiveResource::Base
self.site = "http://37s.sunrise.i:3000"
validates_presence_of :name
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
# stop-gap accessor to default this attribute to nil
# Otherwise the validations fail saying that the method does not exist.
# In future, method_missing will be updated to not explode on a known
# attribute.
def name
attributes['name'] || nil
end
def description
attributes['description'] || nil
end
end
Jump to Line
Something went wrong with that request. Please try again.