{"id":25436708,"url":"https://github.com/pioz/bit_settings","last_synced_at":"2026-04-09T04:01:39.668Z","repository":{"id":62554307,"uuid":"64488670","full_name":"pioz/bit_settings","owner":"pioz","description":"BitSettings is a plugin for ActiveRecord that transform a column of your model in a set of boolean settings.","archived":false,"fork":false,"pushed_at":"2021-10-19T08:01:29.000Z","size":11,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-30T01:44:16.728Z","etag":null,"topics":["activerecord","boolean","rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pioz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-29T14:55:14.000Z","updated_at":"2021-10-19T08:01:32.000Z","dependencies_parsed_at":"2022-11-03T05:00:28.898Z","dependency_job_id":null,"html_url":"https://github.com/pioz/bit_settings","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pioz/bit_settings","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioz%2Fbit_settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioz%2Fbit_settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioz%2Fbit_settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioz%2Fbit_settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pioz","download_url":"https://codeload.github.com/pioz/bit_settings/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioz%2Fbit_settings/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31584817,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"online","status_checked_at":"2026-04-09T02:00:06.848Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activerecord","boolean","rails"],"created_at":"2025-02-17T08:21:50.138Z","updated_at":"2026-04-09T04:01:39.649Z","avatar_url":"https://github.com/pioz.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BitSettings\n\nBitSettings is a plugin for ActiveRecord that transform a column of your model in a set of boolean settings.\nYou can have up to 32 boolean values stored in a single database column.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'bit_settings'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install bit_settings\n\n## Usage\n\nFirst of all add a unsigned int column for your boolean settings with `rails g migration add_settings_to_users settings:integer` and then edit like follow:\n\n```\nclass AddSettingsToUsers \u003c ActiveRecord::Migration\n  def change\n    add_column :users, :settings, 'INT UNSIGNED', null: false, default: 0\n  end\nend\n```\n\nThe max unsigned integer in 4 bytes is `2^32-1 = 4294967295` so with a column you can have max 32 settings.\nIf you want that the default value of your settings is 1 (true) set the default value of the column to `2^32-1`.\n\nThen in your model:\n\n```\nclass User extends ActiveRecord::Base\n  include BitSettings\n  add_settings :disable_notifications, :help_tour_shown\nend\n```\n\nNow you can do:\n\n```\nuser.disable_notifications? # =\u003e false\nuser.help_tour_shown? # =\u003e false\nuser.disable_notifications = true # =\u003e true\nuser.save\n```\n\nYou can also use the scope `with_settings` which takes a hash as parameter like the example below:\n\n```\n# Get all users with the value of setting disable_notifications equal to true\n# and the settings help_tour_shown equal to false.\nusers = User.with_settings(disable_notifications: true, help_tour_shown: false)\n```\n\nAvailable options are `:column` and `:prefix`:\n\n```\nclass User extends ActiveRecord::Base\n  add_settings :disable_notifications, :help_tour_shown, column: :my_settings, prefix: :setting\nend\n```\n\n- `:column` specify the name of the column to use (default is `settings`)\n- `:prefix` add a prefix to dynamic methods\n\n```\nuser.setting_disable_notifications? # =\u003e false\nusers = User.with_settings(setting_disable_notifications: false)\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/pioz/bit_settings.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpioz%2Fbit_settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpioz%2Fbit_settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpioz%2Fbit_settings/lists"}