diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-06-02 12:36:36 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-06-02 12:36:36 -0300 |
commit | fd3c55f09fdfb45c33a5383af2c0b9ddf8f63e90 (patch) | |
tree | 89f6b8eeae81ba9e9f3c43667b234b64a776e649 /activerecord/test/models/reply.rb | |
parent | 5255a81b808c2c947d58df979e6436b1fe1d8157 (diff) | |
parent | 196f780e30fcece25e4d09c12f9b9f7374ebed29 (diff) | |
download | rails-fd3c55f09fdfb45c33a5383af2c0b9ddf8f63e90.tar.gz rails-fd3c55f09fdfb45c33a5383af2c0b9ddf8f63e90.tar.bz2 rails-fd3c55f09fdfb45c33a5383af2c0b9ddf8f63e90.zip |
Merge commit 'rails/master'
Conflicts:
activerecord/lib/active_record.rb
Diffstat (limited to 'activerecord/test/models/reply.rb')
-rw-r--r-- | activerecord/test/models/reply.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/activerecord/test/models/reply.rb b/activerecord/test/models/reply.rb index 1c990acab6..616c07687c 100644 --- a/activerecord/test/models/reply.rb +++ b/activerecord/test/models/reply.rb @@ -11,26 +11,30 @@ class Reply < Topic attr_accessible :title, :author_name, :author_email_address, :written_on, :content, :last_read - def validate - errors.add("title", "Empty") unless attribute_present? "title" + validate :check_empty_title + validate_on_create :check_content_mismatch + validate_on_update :check_wrong_update + + def check_empty_title + errors[:title] << "Empty" unless attribute_present?("title") end def errors_on_empty_content - errors.add("content", "Empty") unless attribute_present? "content" + errors[:content] << "Empty" unless attribute_present?("content") end - def validate_on_create + def check_content_mismatch if attribute_present?("title") && attribute_present?("content") && content == "Mismatch" - errors.add("title", "is Content Mismatch") + errors[:title] << "is Content Mismatch" end end def title_is_wrong_create - errors.add("title", "is Wrong Create") if attribute_present?("title") && title == "Wrong Create" + errors[:title] << "is Wrong Create" if attribute_present?("title") && title == "Wrong Create" end - def validate_on_update - errors.add("title", "is Wrong Update") if attribute_present?("title") && title == "Wrong Update" + def check_wrong_update + errors[:title] << "is Wrong Update" if attribute_present?("title") && title == "Wrong Update" end end |