Docs / Core Concepts / Groups

Groups

Groups let you enable features for categories of users defined by custom logic.

What are Groups?

Groups allow you to define collections of actors based on shared characteristics. Instead of adding individual actor IDs, you define a group once and then enable features for that group.

Registering Groups

Register groups in an initializer. The block receives the actor and should return true/false:

config/initializers/flipper_groups.rb

# Register a group for admin users
Flipper.register(:admins) do |actor|
  actor.respond_to?(:admin?) && actor.admin?
end

# Register a group for beta testers
Flipper.register(:beta_testers) do |actor|
  actor.respond_to?(:beta_tester?) && actor.beta_tester?
end

# Register a group for employees
Flipper.register(:employees) do |actor|
  actor.respond_to?(:email) && actor.email&.ends_with?("@yourcompany.com")
end

Enabling for Groups

Once registered, enable features for groups in the Flagstack dashboard by adding the group name to the Groups gate.


# In the dashboard, add "admins" to the Groups gate
# Then in your code:

admin_user = User.find(1)   # admin? returns true
regular_user = User.find(2) # admin? returns false

Flipper.enabled?(:admin_tools, admin_user)   # => true
Flipper.enabled?(:admin_tools, regular_user) # => false

Common Group Patterns


# Premium subscribers
Flipper.register(:premium) do |actor|
  actor.respond_to?(:subscription) && actor.subscription&.premium?
end

# Users from specific organizations
Flipper.register(:enterprise_orgs) do |actor|
  actor.respond_to?(:organization) && actor.organization&.enterprise?
end

# Users who signed up after a date
Flipper.register(:new_users) do |actor|
  actor.respond_to?(:created_at) && actor.created_at > 1.month.ago
end

Performance Tip

Group checks run on every enabled? call. Keep your group blocks fast and avoid database queries.

© 2026 Flagstack. All rights reserved.