Currently we have .search, which returns a (possibly empty) array of results, and we have .find, which returns a single result or raises ActiveRemote::RemoteRecordNotFound.
We see a common pattern when we know we need only one record, but we want nil instead of raising an error:
RemoteModel.search(:key => value).first
This MR proposes adding a .find_by method to ActiveRemote classes, which would allow us to instead write:
RemoteModel.find_by(:key => value)
The new method would be parallel to the ActiveRecord .find_by method.
Currently we have
.search
, which returns a (possibly empty) array of results, and we have.find
, which returns a single result or raisesActiveRemote::RemoteRecordNotFound
.We see a common pattern when we know we need only one record, but we want
nil
instead of raising an error:This MR proposes adding a
.find_by
method to ActiveRemote classes, which would allow us to instead write:The new method would be parallel to the ActiveRecord
.find_by
method.