active_remote icon indicating copy to clipboard operation
active_remote copied to clipboard

Add `find_by` to the Search module

Open moveson opened this issue 5 years ago • 0 comments

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.

moveson avatar Aug 26 '20 23:08 moveson