Rails 4 deprecates the old-style finder option hashes, as well as all dynamic finder methods (with the exception of
find_by_...
and find_by_...
). Instead, you'll use where
:-
find_all_by_...
can be rewritten usingwhere(...)
. -
find_last_by_...
can be rewritten usingwhere(...).last
. -
scoped_by_...
can be rewritten usingwhere(...)
. -
find_or_initialize_by_...
can be rewritten usingwhere(...).first_or_initialize
. -
find_or_create_by_...
can be rewritten usingfind_or_create_by(...)
orwhere(...).first_or_create
. -
find_or_create_by_...!
can be rewritten usingfind_or_create_by!(...)
orwhere(...).first_or_create!
.
The deprecated finders gem will be included as a dependency in 4.0. and removed in 4.1. The gem, however, will be around and maintained until 5.0.