Notes posted by matrix9180
RSS feed![Default_avatar_30](https://www.gravatar.com/avatar/103b38179a1aa3eaef26ed700fce55b9?default=http://apidock.com/images/default_avatar_30.png&size=30)
4 thanks
Be careful with overriding dynamic attribute based finders
don’t try something like this:
class Foo < ActiveRecord::Base def self.find_by_bar(*args) foo = super(*args) raise SomeCustomException unless foo foo end end
In newer versions of rails, method_missing defines find_by_bar when you first use it. By calling super, you’re triggering method_missing and overwriting your custom definition! It will work the first time then break! Manually write the call to find!