This project is archived and is in readonly mode.
find_by_xxx! bang method, have better error messages
Reported by Zach Dennis | December 12th, 2008 @ 09:49 PM | in 2.x
It would be nice if the find_by_xxx! bang methods gave nicer error messages. Right now you get:
> Expense.find_by_amount(10)
=> nil
>> Expense.find_by_amount!(10)
ActiveRecord::RecordNotFound: ActiveRecord::RecordNotFound
It would be better if the error produced was:
ActiveRecord::RecordNotFound: no Expense found with amount => 10
Comments and changes to this ticket
-
Frederick Cheung December 14th, 2008 @ 01:52 PM
- Tag changed from featurerequest, rails to activerecord, featurerequest, patch, rails
This should do it. If you use find_by_xxx_and_yyy! then the exception's message will be along the lines of
Couldn't find Asset with xxx = 123, yyy = 456
-
Repository December 18th, 2008 @ 07:22 PM
- State changed from new to resolved
(from [428e77bf0fcee4369cb8d94011141f791b8e2ba9]) Make exceptions raise from find_by_foo! have a more helpful message [#1567 state:resolved] http://github.com/rails/rails/co...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 1567 find_by_xxx! bang method, have better error messages (from [428e77bf0fcee4369cb8d94011141f791b8e2ba9]) Make ex...