root/trunk/actionpack/lib/action_controller/assertions/model_assertions.rb
| Revision 8284, 0.5 kB (checked in by marcel, 1 year ago) |
|---|
| Line | |
|---|---|
| 1 | module ActionController |
| 2 | module Assertions |
| 3 | module ModelAssertions |
| 4 | # Ensures that the passed record is valid by ActiveRecord standards and returns any error messages if it is not. |
| 5 | # |
| 6 | # ==== Examples |
| 7 | # |
| 8 | # # assert that a newly created record is valid |
| 9 | # model = Model.new |
| 10 | # assert_valid(model) |
| 11 | # |
| 12 | def assert_valid(record) |
| 13 | clean_backtrace do |
| 14 | assert record.valid?, record.errors.full_messages.join("\n") |
| 15 | end |
| 16 | end |
| 17 | end |
| 18 | end |
| 19 | end |
Note: See TracBrowser for help on using the browser.