diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-08-19 11:09:24 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-08-19 11:09:24 -0300 |
commit | b3427286771bb476c0c4a58488033bd671740332 (patch) | |
tree | 616c38e8ca5606e06c7f2fbfa7b732b38d2eaec4 /activeresource/test/fixtures | |
parent | 2048556a14c28f9814f9c6ad44a08084afec1afe (diff) | |
parent | 328ba3b333777bbc1269cbe0e9f590c845006c9d (diff) | |
download | rails-b3427286771bb476c0c4a58488033bd671740332.tar.gz rails-b3427286771bb476c0c4a58488033bd671740332.tar.bz2 rails-b3427286771bb476c0c4a58488033bd671740332.zip |
Merge commit 'rails/master'
Diffstat (limited to 'activeresource/test/fixtures')
-rw-r--r-- | activeresource/test/fixtures/project.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/activeresource/test/fixtures/project.rb b/activeresource/test/fixtures/project.rb new file mode 100644 index 0000000000..e15fa6f620 --- /dev/null +++ b/activeresource/test/fixtures/project.rb @@ -0,0 +1,25 @@ +# 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 + |