Get Started with Flipper Cloud on Rails
In addition to the steps outlined below, we have a fully functional example Rails application for you to peruse.
Step 1. Add Flipper to your app
It's recommended to persist your Flipper configuration locally with an adapter of your choice (e.g. ActiveRecord, Redis, Sequel, Mongo, or several other adapters). You can decide this later if you don't know which one you want now.
bundle add flipper-active_record
bin/rails g flipper:setup
bin/rails db:migrate
You'll need to set the following ENV
variable:
FLIPPER_CLOUD_TOKEN=<your-token-here>
Step 2. Use Flipper in your code
Use Flipper#enabled?
in your app for anything you want to gate access to, such as rolling out new features, taking parts of your system offline for maintenance without disrupting everyone else, or any other reason.
For example, here we check if the search feature of our app is enabled:
search_controller.rb
before_action :ensure_search_enabled
def ensure_search_enabled
render :unavailable unless Flipper.enabled?(:search)
end
Now flip this feature on for different segments of your users:
# 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 enabling features.
Done
That's it. For a couple lines of code and a couple of clicks you get the full power of feature toggles with little to no performance impact.
Need Help?
We would be delighted to answer any questions or even setup a pairing session to help you get your application setup correctly. Shoot an email to support@flippercloud.io.
Get audit history, rollbacks, advanced permissions, analytics, and all of your projects in one place.
You can choose from several tiers to sponsor Flipper on GitHub and get some great benefits!