{"id":17599116,"url":"https://github.com/iguchi1124/cookie_flag","last_synced_at":"2025-04-30T06:28:10.321Z","repository":{"id":28303029,"uuid":"117677575","full_name":"iguchi1124/cookie_flag","owner":"iguchi1124","description":"Cookie based feature flags implementation for Rails.","archived":false,"fork":false,"pushed_at":"2022-04-19T20:07:40.000Z","size":112,"stargazers_count":20,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-14T06:18:42.098Z","etag":null,"topics":["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/iguchi1124.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-16T11:53:59.000Z","updated_at":"2023-01-17T16:27:27.000Z","dependencies_parsed_at":"2022-08-07T13:15:41.811Z","dependency_job_id":null,"html_url":"https://github.com/iguchi1124/cookie_flag","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iguchi1124%2Fcookie_flag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iguchi1124%2Fcookie_flag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iguchi1124%2Fcookie_flag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iguchi1124%2Fcookie_flag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iguchi1124","download_url":"https://codeload.github.com/iguchi1124/cookie_flag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251653447,"owners_count":21622127,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["rails"],"created_at":"2024-10-22T10:09:15.095Z","updated_at":"2025-04-30T06:28:10.299Z","avatar_url":"https://github.com/iguchi1124.png","language":"Ruby","readme":"# CookieFlag\n\nCookie based feature flags implementation for Rails.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'cookie_flag'\n```\n\nAnd then execute:\n\n```shell\n$ bundle\n$ bundle exec rails generate cookie_flag:install\n```\n\n## Usage\n\nAt first, edit your `config/cookie_flag.yml` and configure your feature flag name and feature flag secret.\n\n```yml\ndefault: \u0026default\n  new_feature: '1'\n\ndevelopment:\n  \u003c\u003c: *default\n\ntest:\n  \u003c\u003c: *default\n\nproduction:\n  new_feature: \u003c%= ENV['NEW_FEATURE_SECRET'] %\u003e\n```\n\nthen, you can use cookie based feature flag API at controllers and views.\n\nIf you want to enable or disable features from admin page, you can use console web.\n\nEdit your `config/routes.rb`\n\n```rb\nRails.application.routes.draw do\n  mount CookieFlag::Console, at: \"/cookie_flag\" if Rails.env.development?\nend\n```\n\n### Controllers\n\nUse `feature` class method at controller, you can return 404 response at disabled feature endpoints.\n\n```rb\nclass YourFeaturesController \u003c ApplicationController\n  feature :new_feature\n\n  def index\n  end\nend\n```\n\nAnd some helper methods `feature_available?` and `feature_flags` are available.\n\n```rb\nclass NewFeaturesController \u003c ApplicationController\n  def index\n    unless feature_available?(:new_feature)\n      redirect_to root_path\n    end\n  end\nend\n```\n\n### Views\n\n`feature_available?` helper method is available.\n\n```erb\n\u003c% if feature_available?(:new_feature) %\u003e\n  \u003cp\u003eyou can use new feature!\u003c/p\u003e\n\u003c% else %\u003e\n  \u003cp\u003eyou cannot use new feature!\u003c/p\u003e\n\u003c% end %\u003e\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/iguchi1124/cookie_flag.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figuchi1124%2Fcookie_flag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figuchi1124%2Fcookie_flag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figuchi1124%2Fcookie_flag/lists"}