No, those 'dynamic finders' based on your attribute names aren't get removed. If you have an attribute name `hash`, you should be able to still do `User.find_by_hash!`
See the list of deprecated methods here: http://edgeguides.rubyonrails.org/4_0_release_notes.html#active-record-deprecations -Prem On Wednesday, March 6, 2013 at 10:38 PM, Nick Ostrovsky wrote: > > > > > Hi, > > > I propose to add #where! finder that raises an exception if the relation is > empty like find_by_xxx! method in Rails3. > > > Rails 4 is getting rid of dynamic finders, so > > > User.find_by_hash(hash) > > > becomes > > > User.where(hash: hash) # .first > > > Okay, not a big deal. But what is the best way to deal do with dynamic bang > finders like User.find_by_hash!(hash) since there is no where!() method? > > > A suggestion I got on Stackoverflow > (http://stackoverflow.com/questions/14372963/dynamic-bang-finders-in-rails-4/15257207) > is to add a #where! method. > > > If you need a method that finds all but raises exception if the relation is > empty, you can create such new method for your models yourself (or mixin to > ActiveRecord::QueryMethods). Something like: > > > def where!(*args) > > > rel = where(*args) > > > raise RecordNotFound if rel.empty? > > > rel > > > end > > > > > > > > > > > -- > > > Nick > > > -- > 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 [email protected] > (mailto:[email protected]). > To post to this group, send email to [email protected] > (mailto:[email protected]). > Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
