Quickly add bitfield scopes to an active record model
Add this line to your application's Gemfile:
gem 'bitfield_flags'
And then execute:
$ bundle
Or install it yourself as:
$ gem install bitfield_flags
class User < ActiveRecord::Base
include BitfieldFlags
scoped_flags %w(
is_admin
is_customer_service
legacy_user
)
# ...snip...
end
User.is_admin #=> Returns all users with the 'is_admin' bitfield turned on
user = User.first
user.is_admin? #=> true or false depending on the is_admin bitfield state- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request