Coming soon! A Pro version of the Flipper gem for entirely local installations.

Get Updates

Documentation

Actors

Enable features for a specific user, organization, or any other unique record. These are all called "Actors" in Flipper.

To check if a feature is enabled for an actor, pass the object to the Flipper.enabled? check:

enabled?(:feature, actor)
user = User.first

# Check if enabled without an actor
Flipper.enabled?(:verbose_logging) # false

# Check if enabled for the given user
Flipper.enabled?(:verbose_logging, user) # false

You can check multiple related actors in the same feature check, and it will return true if enabled for any of the given actors:

enabled? with multiple actors
Flipper.enabled?(:verbose_logging, user, user.organizations, user.teams)

Enabling for an actor

To enable a feature for a specific actor, use enable_actor:

enable_actor
Flipper.enable_actor(:verbose_logging, user)

# Check if enabled without an actor
Flipper.enabled?(:verbose_logging) # false

# Check if enabled for the given user
Flipper.enabled?(:verbose_logging, user) # true

# Check if enabled for a different actor
Flipper.enabled?(:verbose_logging, User.last) # false

Limitations

enable_actor is not designed to handle hundreds or thousands of actors. This is an explicit choice to make it easier to batch load data from the adapters instead of performing individual checks for actors over and over.

If you need support for large actor sets, check out the flipper-pro gem, or use Groups to enable features for actors that match custom criteria.

As of Flipper 1.3.0, there is a default limit of 100 actors per feature to prevent unexpected performance impacts. We don't advise it, but if needed, you can change this default by setting the actor_limit option:

Change actor_limit default
Rails.application.configure do
  # Increase the actor limit (not recommended)
  config.flipper.actor_limit = 1000

  # or disable this check entirely (not recommended)
  config.flipper.actor_limit = false
end

flipper_id

An actor is any object that responds to #flipper_id. This is defined by default on all ActiveRecord objects, and for other objects you can include the Flipper::Identifier module for a default implementation which combines the class name and id.

Flipper::Identifier
class User < Struct.new(:id)
  include Flipper::Identifier
end

User.new(5).flipper_id # => "User;5"

You can also define your own implementation:

Custom #flipper_id
class Organization < Struct.new(:uuid)
  def flipper_id
    uuid
  end
end

Organization.new("DEB3D850-39FB-444B-A1E9-404A990FDBE0").flipper_id
# => "DEB3D850-39FB-444B-A1E9-404A990FDBE0"

Just make sure each type of object has a unique flipper_id.

Disabling for an actor

Use disable_actor to remove an actor from the list of actors for a feature.

disable_actor
Flipper.disable_actor(:verbose_logging, user)

NOTE
You cannot use disable_actor to turn off a feature that is enabled for all actors. The disable* methods exist only to clear something previously enabled. Use Groups to enable a feature for a subset that excludes certain actors.

Ready to try it out?

Get audit history, rollbacks, advanced permissions, analytics, and all of your projects in one place.


Prefer our Cloudless option?

You can choose from several tiers to sponsor Flipper on GitHub and get some great benefits!

The Friday Deploy

Get updates for all things Flipper—open source and cloud.

Have questions? Need help?

Email us any time or head on over to our documentation or status page for the latest on the app or API.

Ready to take Flipper for a swim?

No credit card required. 14-day free trial. And customer support directly from the developers.