Ruby on Rails

In this guide, you'll learn how to add Rollout integrations in your Rails app.


To complete this guide, you will need:

  • A Rollout account
  • Docker: download from
  • A local dev tunnel like ngrok

1. Create a Rollout project and run it locally#

Clone the starter template. You can clone it in the root of your Rails app or keep it in a separate repo:

# In your terminal
$ git clone rollout
$ cd rollout
# Install dependencies
$ yarn

Tip: Remember to delete the git reference by calling rm -rf .git in the root of the Rollout project

To run your Rollout project locally:

  1. Run ngrok and forward to local port 3300
ngrok http 3300
  1. Open Docker Desktop
  2. Start running your Rollout project. In the root of your project, run the command:

You can find your project key at and your tunnel URL in step 1

$ yarn rollout dev --project-key=YOUR_PROJECT_KEY --tunnel-url=YOUR_TUNNEL_URL

When you go to your dashboard, you should see an environment labeled LOCAL for your local development. Clicking on this environment will let you see your local ROLLOUT_CLIENT_SECRET:

2. Create an Integrations page and generate a Rollout token#

You can render Rollout integrations on any page, for simplicity we will generate a new page and controller.

Add a new route

# In your config/routes/rb
Rails.application.routes.draw do
get "/integrations", to: "integrations#index"

Generate the controller

bin/rails generate controller Integrations index --skip-routes

Add the jwt package to your app

bundle add jwt

Finally, update your Integrations controller like so:

# In app/controllers/integrations_controller.rb
require 'jwt'
class IntegrationsController < ApplicationController
def index
def generate_jwt
@rollout_token = JWT.encode(
iss: ENV['ROLLOUT_PROJECT_KEY'], # Provided in the Rollout dashboard
sub: current_user[:id].to_s, # Persistent ID for the current user
iat:, # Time token was generated
exp: + 60 * 10000 # Token expiration
ENV['ROLLOUT_CLIENT_SECRET'], # Provided in the Rollout dashboard

3. Render a Rollout UI Component in your app#

In your view, add the following code to render the AutomationsManager component

<div id="rollout-container"></div>
<script src=""></script>
const container = document.getElementById("rollout-container");
const apiBaseUrl = "http://localhost:3300/api";
const token = "<%= @rollout_token %>";
const ro = window.Rollout.init({token, apiBaseUrl });

Code Example#

Read the source code or try it yourself by running this example repository: