Get Started with Flipper Cloudless 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
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 many other reasons.
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.
Step 3. Add the Flipper Web UI or API (Optional)
With Flipper Cloud, the app provides a web interface, but with self-hosted, you can install a simple web interface using the open source flipper-ui
gem. Or you can skip the Flipper UI and use the Flipper to build feature-toggling functionality directly into your existing administrative tools.
Visit the flipper-ui
installation guide if you want to install the Flipper control panel in your app.
Or, if you have external administrative tools, you can add the flipper-api
gem to integrate with external tools.
Step 4. Subscribe to the Newsletter for Updates (Optional)
Stay up-to-date on new releases of the Flipper gem by subscribing to the newsletter.
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.
If you're ever ready to upgrade to Flipper Cloud, there's a guide for migrating from Cloudless to Cloud that should get you going in no time.
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!