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.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