# Get Started with Flipper Cloud on Rails

> Connect a Rails app to Flipper Cloud in a few minutes: add the gem, set FLIPPER_CLOUD_TOKEN, and gate any code path with a feature flag.

In addition to the steps outlined below, we have a fully functional [example Rails application](https://github.com/flippercloud/flipper-rails-demo) 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](/docs/adapters/active-record), [Redis](/docs/adapters/redis), [Sequel](/docs/adapters/sequel), [Mongo](/docs/adapters/mongo), or several [other adapters](/docs/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:

```bash
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`
```ruby
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:

```ruby
# 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](/docs/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.

## What if Flipper Cloud goes down?

Your app won't even notice. Every feature flag check reads from a copy of your flags in your app &mdash; zero calls to Flipper Cloud at runtime. Cloud syncs happen in the background, so if Flipper Cloud is ever unreachable, your app keeps running with the last known feature flag state. Learn more about [how Flipper Cloud is designed to never take your app down](/resilience).

## 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 <a href="mailto:support@flippercloud.io?subject=I%20need%20help%20getting%20started">support@flippercloud.io</a>.
