Actors
Actors represent individual entities that can be targeted by feature flags, typically users.
What is an Actor?
An actor is any object that can be uniquely identified for feature flag targeting. Most commonly, actors are users, but they can be any entity with a unique identifier.
Implementing flipper_id
For an object to be an actor, it must respond to flipper_id:
app/models/user.rb
class User < ApplicationRecord
# Return a unique identifier for this user
def flipper_id
"User;#{id}"
end
end
The format ClassName;id is recommended to avoid collisions between different actor types.
Enabling for Specific Actors
In the Flagstack dashboard, you can add specific actor IDs to enable a feature for just those actors:
# Check if feature is enabled for a specific user
user = User.find(123)
Flipper.enabled?(:beta_feature, user) # => true (if User;123 is in actors list)
# Other users won't see it
other_user = User.find(456)
Flipper.enabled?(:beta_feature, other_user) # => false
Non-User Actors
Actors don't have to be users. Any object can be an actor:
class Organization < ApplicationRecord
def flipper_id
"Organization;#{id}"
end
end
# Enable for a specific organization
org = Organization.find(1)
Flipper.enabled?(:enterprise_feature, org)
Actor IDs in the Dashboard
When adding actors in the Flagstack dashboard, enter the full flipper_id:
User;123— enables for user with ID 123Organization;456— enables for organization with ID 456