Top Related Projects
Ruby on Rails
Classy web-development dressed in a DSL (official / canonical repo)
The web, with simplicity.
Use Turbo in your Ruby on Rails app
The advanced business logic framework for Ruby.
Quick Overview
Flipper is a feature flagging and configuration management system for Ruby and Rails applications. It allows developers to enable or disable features dynamically, perform A/B testing, and manage application configurations without requiring code deployments.
Pros
- Easy integration with Ruby and Rails applications
- Supports multiple adapters for storing feature flags (e.g., ActiveRecord, Redis, Memory)
- Provides a web UI for managing features and groups
- Offers a flexible API for programmatically controlling features
Cons
- Primarily focused on Ruby ecosystem, limiting its use in other languages
- May introduce additional complexity to smaller projects
- Requires careful management to avoid cluttering codebase with feature flags
- Performance impact when using certain adapters (e.g., database queries)
Code Examples
- Basic feature flag usage:
Flipper.enabled?(:new_feature)
This code checks if the "new_feature" flag is enabled.
- Enabling a feature for a specific user:
Flipper.enable_actor(:premium_content, user)
This code enables the "premium_content" feature for a specific user.
- Percentage rollout:
Flipper.enable_percentage_of_actors(:beta_feature, 25)
This code enables the "beta_feature" for 25% of users.
- Using feature flags in conditional statements:
if Flipper.enabled?(:new_ui)
render 'new_ui'
else
render 'old_ui'
end
This code renders different views based on whether the "new_ui" feature is enabled.
Getting Started
- Add Flipper to your Gemfile:
gem 'flipper'
gem 'flipper-ui'
gem 'flipper-active_record'
- Run bundle install:
bundle install
- Set up Flipper in your Rails application:
# config/initializers/flipper.rb
require 'flipper/adapters/active_record'
Flipper.configure do |config|
config.default do
adapter = Flipper::Adapters::ActiveRecord.new
Flipper.new(adapter)
end
end
- Mount the Flipper UI in your routes:
# config/routes.rb
Rails.application.routes.draw do
mount Flipper::UI.app(Flipper) => '/flipper'
end
Now you can use Flipper in your application and access the UI at /flipper
.
Competitor Comparisons
Ruby on Rails
Pros of Rails
- Comprehensive web application framework with a vast ecosystem
- Follows convention over configuration, speeding up development
- Extensive built-in testing tools and generators
Cons of Rails
- Steeper learning curve for beginners
- Can be overkill for smaller projects
- Performance can be slower compared to lighter frameworks
Code Comparison
Rails (config/routes.rb):
Rails.application.routes.draw do
resources :users
root 'home#index'
end
Flipper (example usage):
Flipper.enable :new_feature
if Flipper.enabled? :new_feature
# New feature code
end
Summary
Rails is a full-featured web application framework, while Flipper is a feature flag system. Rails provides a complete solution for building web applications, including routing, ORM, and view rendering. Flipper, on the other hand, focuses solely on feature toggling, allowing developers to enable or disable features dynamically.
Rails is better suited for large, complex web applications that require a comprehensive framework. Flipper is ideal for implementing feature flags in existing applications, regardless of the framework used.
The code comparison shows Rails' routing configuration, demonstrating its convention-based approach. Flipper's code snippet illustrates its simple API for enabling and checking feature flags.
Classy web-development dressed in a DSL (official / canonical repo)
Pros of Sinatra
- Lightweight and minimalist web framework, offering simplicity and flexibility
- Extensive documentation and large community support
- Ideal for small to medium-sized applications and APIs
Cons of Sinatra
- Less suitable for complex, large-scale applications compared to Flipper
- Fewer built-in features, requiring more manual configuration
- Limited out-of-the-box support for advanced routing and middleware
Code Comparison
Sinatra:
require 'sinatra'
get '/' do
'Hello, World!'
end
Flipper:
require 'flipper'
Flipper.configure do |config|
config.default { |feature| feature.enable_percentage_of_time 10 }
end
Summary
Sinatra is a lightweight web framework focused on simplicity, while Flipper is a feature flag system for controlling application behavior. Sinatra excels in creating small to medium-sized web applications with minimal overhead, whereas Flipper specializes in managing feature toggles and gradual rollouts. The code examples demonstrate Sinatra's straightforward route definition and Flipper's feature flag configuration. While both serve different purposes, they can be complementary in a Ruby ecosystem, with Sinatra handling web requests and Flipper managing feature availability.
The web, with simplicity.
Pros of Hanami
- Full-featured web application framework with a modular architecture
- Emphasis on clean, maintainable code and separation of concerns
- Built-in security features and performance optimizations
Cons of Hanami
- Steeper learning curve for developers new to the framework
- Smaller community and ecosystem compared to more popular Ruby frameworks
Code Comparison
Hanami:
# config/routes.rb
root to: 'home#index'
resources :books, only: [:index, :show]
Flipper:
# config/routes.rb
Flipper::UI.configure do |config|
config.banner_text = 'My Awesome App'
end
mount Flipper::UI.app(Flipper) => '/flipper'
Key Differences
- Hanami is a full-stack web framework, while Flipper is a feature flag system
- Hanami focuses on application structure and maintainability, whereas Flipper specializes in feature toggling
- Hanami provides a complete MVC architecture, while Flipper integrates into existing applications
Use Cases
- Hanami: Building complex, scalable web applications with a focus on clean architecture
- Flipper: Implementing feature flags and gradual rollouts in existing Ruby applications
Community and Support
- Hanami has a growing community but is less popular than Rails
- Flipper has a dedicated following for feature flag management in Ruby projects
Use Turbo in your Ruby on Rails app
Pros of Turbo Rails
- Seamless integration with Rails, providing a smooth development experience
- Offers real-time updates and partial page reloads, enhancing user experience
- Built-in support for form submissions and redirects without full page reloads
Cons of Turbo Rails
- Limited to Rails applications, unlike Flipper's language-agnostic approach
- Steeper learning curve for developers new to the Hotwire ecosystem
- May require more client-side JavaScript compared to Flipper's server-side focus
Code Comparison
Turbo Rails (view component):
<%= turbo_frame_tag "messages" do %>
<%= render @messages %>
<% end %>
Flipper (feature flag check):
if Flipper.enabled?(:new_feature, current_user)
# New feature code
else
# Old feature code
end
While Turbo Rails focuses on enhancing the frontend experience with real-time updates and partial page reloads, Flipper is primarily used for feature flagging and gradual rollouts. Turbo Rails is tightly integrated with Rails applications, whereas Flipper can be used across various languages and frameworks. The code examples demonstrate their different use cases: Turbo Rails for dynamic content updates and Flipper for conditional feature enabling.
The advanced business logic framework for Ruby.
Pros of Trailblazer
- Provides a comprehensive architecture for Ruby applications
- Offers a modular approach with separate gems for different functionalities
- Encourages better code organization and separation of concerns
Cons of Trailblazer
- Steeper learning curve due to its complex architecture
- May be overkill for smaller projects or simpler applications
- Less active community and fewer contributors compared to Flipper
Code Comparison
Trailblazer (Operation example):
class Create < Trailblazer::Operation
step Model(User, :new)
step Contract::Build(constant: UserContract)
step Contract::Validate()
step Contract::Persist()
end
Flipper (Feature flag example):
Flipper.enable :search
Flipper.enabled? :search
Flipper.disable :search
Trailblazer focuses on structuring business logic and workflows, while Flipper is specifically designed for feature flagging. Trailblazer's code tends to be more verbose and structured, whereas Flipper's API is simpler and more focused on toggling features.
Trailblazer is better suited for complex applications that require a well-defined architecture, while Flipper excels in providing a straightforward way to manage feature flags across different environments and user groups.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Website | Documentation | Examples | Chat | Twitter | Ruby.social
Flipper
Beautiful, performant feature flags for Ruby and Rails.
Flipper gives you control over who has access to features in your app.
- Enable or disable features for everyone, specific actors, groups of actors, a percentage of actors, or a percentage of time.
- Configure your feature flags from the console or a web UI.
- Regardless of what data store you are using, Flipper can performantly store your feature flags.
- Use Flipper Cloud to cascade features from multiple environments, share settings with your team, control permissions, keep an audit history, and rollback.
Control your software — don't let it control you.
Installation
Add this line to your application's Gemfile:
gem 'flipper'
You'll also want to pick a storage adapter, for example:
gem 'flipper-active_record'
And then execute:
$ bundle
Or install it yourself with:
$ gem install flipper
Subscribe & Ship
ð Subscribe - we'll send you short and sweet emails when we release new versions (examples).
Getting Started
Use Flipper#enabled?
in your app to check if a feature is enabled.
# check if search is enabled
if Flipper.enabled?(:search, current_user)
puts 'Search away!'
else
puts 'No search for you!'
end
All features are disabled by default, so you'll need to explicitly enable them.
# Enable a feature for everyone
Flipper.enable :search
# Enable a feature for a specific actor
Flipper.enable_actor :search, current_user
# Enable a feature for a group of actors
Flipper.enable_group :search, :admin
# Enable a feature for a percentage of actors
Flipper.enable_percentage_of_actors :search, 2
Read more about getting started with Flipper and enabling features.
Flipper Cloud
Like Flipper and want more? Check out Flipper Cloud, which comes with:
- multiple environments — production, staging, per continent, whatever you need. Every environment inherits from production by default and every project comes with a project overview page that shows each feature and its status in each environment.
- personal environments — everyone on your team gets a personal environment (that inherits from production) which they can modify however they want without stepping on anyone else's toes.
- permissions — grant access to everyone in your organization or lockdown each project to particular people. You can even limit access to a particular environment (like production) to specific people.
- audit history — every feature change and who made it.
- rollbacks — enable or disable a feature accidentally? No problem. You can roll back to any point in the audit history with a single click.
- maintenance — we'll keep the lights on for you. We also have handy webhooks and background polling for keeping your app in sync with Cloud, so our availability won't affect yours. All your feature flag reads are local to your app.
- everything in one place — no need to bounce around from different application UIs or IRB consoles.
Cloud is super simple to integrate with Rails (demo app), Sinatra or any other framework.
We also have a free plan that you can use forever.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Run the tests (
bundle exec rake
). Check out Docker-Compose if you need help getting all the adapters running. - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Releasing
- Update the version to be whatever it should be and commit.
script/release
- Create a new GitHub Release
Brought To You By
pic | @mention | area |
---|---|---|
@jnunemaker | most things | |
@bkeepers | most things | |
@dpep | tbd | |
@alexwheeler | api | |
@thetimbanks | ui | |
@lazebny | docker | |
@pagertree | sponsor | |
@kdaigle | sponsor |
Top Related Projects
Ruby on Rails
Classy web-development dressed in a DSL (official / canonical repo)
The web, with simplicity.
Use Turbo in your Ruby on Rails app
The advanced business logic framework for Ruby.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot