Skip to content

joshuaflanagan/activerecord-find_only

Repository files navigation

ActiveRecord::FindOnly

Provides the #find_only and #find_only! methods for querying ActiveRecord objects.

#find_only - returns the only record that meets the criteria. If no records match the criteria, nil is returned. Raises TooManyRecords if more than one records matches the criteria.

#find_only! - returns the only record that meets the criteria. If no records match the criteria, RecordNotFound is raised. Raises TooManyRecords if more than one records matches the criteria.

Installation

Add this line to your application's Gemfile:

gem 'active_record-find_only'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_record-find_only

Usage

See the spec files for example usage.

License

The gem is available as open source under the terms of the MIT License.

About

Provide methods to find the only record that meets a criteria

Resources

License

Stars

Watchers

Forks

Packages

No packages published