Skip to content

Conversation

@dmitrytrager
Copy link
Collaborator

Credentials-based feature flags adapted from Rails 8.2 pattern for 8.1, using Rails.application.credentials.dig instead of Rails.app.creds.option. Supports per-user targeting via allowed_emails, ENV overrides, and request-scoped toggles for testing. Beacons feature gated to admin@skillrx.org.

What Issue Does This PR Cover, If Any?

Resolves #587

What Changed? And Why Did It Change?

I borrow this approach from article: https://codewithrails.com/blog/rails-feature-flags-credentials/
It can work for us since it is dependency-free

How Has This Been Tested?

Please Provide Screenshots

Additional Comments

dmitrytrager and others added 2 commits February 4, 2026 15:59
Credentials-based feature flags adapted from Rails 8.2 pattern for 8.1,
using Rails.application.credentials.dig instead of Rails.app.creds.option.
Supports per-user targeting via allowed_emails, ENV overrides, and
request-scoped toggles for testing. Beacons feature gated to admin@skillrx.org.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… spec

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@@ -0,0 +1,62 @@
module FeatureFlags
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to move it to services

module FeatureFlags
extend self

def enabled?(flag_name, user: nil)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use overrides, env vars and setup from creadentials

def user_allowed?(config, user)
return false if user.nil?

allowed_emails = config[:allowed_emails]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to identify users in a different way later

@dmitrytrager dmitrytrager marked this pull request as ready for review February 4, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature flags

2 participants