On Feb 8, 2015, at 11:07 AM, Иван Бишевац <ivan.bise...@gmail.com> wrote:
> User.find(1) > for no record with gives: > > def test_error_message > begin > User.find(1) > rescue ActiveRecord::RecordNotFound => e > message = e.message > end > > assert_equal message, "Couldn't find User with 'id'=1" > end > > > I expected same behavior wiht find_by! method but it doesn't give so > descriptive message. > For example expected behavior should be: > > def test_error_message_for_find_by! > begin > User.find_by(first_name: 'foo', last_name: 'bar') > rescue ActiveRecord::RecordNotFound => e > message = e.message > end > > assert_equal message, "Couldn't find User with 'first_name'='foo' and > 'last_name'='bar'" > end > > but it doesn't work like this instead e.message is just general "Couldn't > find User”. See also discussion on this PR: https://github.com/rails/rails/pull/15791 and the related issue: https://github.com/rails/rails/issues/15792 —Matt Jones -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: Message signed with OpenPGP using GPGMail