Categories: None [Edit]
boxey
Boxey provides the [] element reference operator to ActiveRecord classes.
# Installation
Add this line to your Gemfile:
`gem 'boxey'`
# Configuration
With the boxey gem installed, all ActiveRecord classes gain the [] method, which fetches by the class's primary_key by default.
You may specify additional fields, presumably fields that validate uniqueness, by calling the boxey method.
class User < ActiveRecord::Base
boxey :id, :login, :email
validates :login, uniqueness: true
validates :email, uniqueness: true
end
# Use
Given the configuration above:
`User[1]` returns the first User with an id (or login or email) of `1`.
`User['[email protected]']` returns the first User with an email (or id or login) of `'[email protected]'`.
`[]` returns `nil` if no match is found.
Total
Ranking: 53,792 of 187,988
Downloads: 20,059
Daily
Ranking: 78,133 of 187,967
Downloads: 1
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 29 | 930,679,140 | rspec |
| 36 | 726,531,445 | activerecord |
| 10,432 | 266,410 | acts_as_fu |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | roguevalley |