public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Make exceptions raise from find_by_foo! have a more helpful message [#1567 
state:resolved]
fcheung (author)
Wed Dec 17 15:37:55 -0800 2008
lifo (committer)
Thu Dec 18 11:19:35 -0800 2008
commit  428e77bf0fcee4369cb8d94011141f791b8e2ba9
tree    86b37e8e7b7b75b8dec2afe0bbcbc5b0a5b8045c
parent  a9fde9a2abd6a6505d5fd197ad9640470d8df9be
...
1829
1830
1831
1832
 
1833
1834
1835
...
1829
1830
1831
 
1832
1833
1834
1835
0
@@ -1829,7 +1829,7 @@ module ActiveRecord #:nodoc:
0
                   else
0
                     find(:#{finder}, options.merge(finder_options))
0
                   end
0
-                  #{'result || raise(RecordNotFound)' if bang}
0
+                  #{'result || raise(RecordNotFound, "Couldn\'t find #{name} with #{attributes.to_a.collect {|pair| "#{pair.first} = #{pair.second}"}.join(\', \')}")' if bang}
0
                 end
0
               }, __FILE__, __LINE__
0
               send(method_id, *arguments)

Comments