Ruby Feature Flags

Split's Ruby SDK brings robust, scalable feature flag management to Ruby and Rails, giving any team the power to safely launch features and target them to users.

Begin your free trial today.

Why use Split for Ruby?

Split’s Ruby and Ruby on Rails SDKs bring free, scalable feature flagging to any app, website or experience built in Ruby. Split helps teams control rollouts, and customer experiences, while gathering new data and insight on how their products are being engaged. With Split, teams can:

  • Release features to production but disabled for all users by default
  • Target new features only to internal QA teams
  • Slowly roll out features to a broader audience by percentage, demographic, geography, account type, or any other metric
  • Kill features with a single click to revert back to your safe state

Split works across many different languages, letting developers, PMs and support teams control feature rollout from one unified view—and monitor the success of any new code. Our integrations bring rollout updates into the tools your team is already using, further opening the feature-delivery process up to your entire organization.

Rails, Sinatra, Cuba, Volt...

If it’s a Ruby framework, Split works with it, giving you quick and easy feature flags (aka feature toggles, feature flags, or feature switches) across your entire stack.

See how thredUP uses Split in Ruby (and Node.JS) to safely launch features and target deals.

Dan DeMeyere, VP Engineering, thredUP

Getting Started with Split for Ruby

Split's Ruby SDK is very simple to integrate into your code base and is completely open source. All it really takes to get rolling with Split is initiating the SDK, then splitting your code.

Initiating the SDK

First, import the SDK into your project:

          gem install splitclient-rb -v '~> 4.1.0'

The instantiate the SDK and create a new Split client:

require 'splitclient-rb'

options = {block_until_ready: 10}
split_factory ="YOUR_API_KEY", options)
split_client = split_factory.client

We recommend instantiating the Factory once as a singleton and reusing it throughout your application.

Include the API key for the environment you are setting up the SDK for. The API key is available under your Organization Settings page, under the APIs tab. The API key is of type sdk**

Splitting your code.

With the SDK instantiated, it’s now time to start splitting your code base. Find a feature you’d like to split, and wrap it in the split feature flag like so:

treatment = split_client.get_treatment("CUSTOMER_ID", "SPLIT_NAME");

if treatment == "on"
  # insert code here to show on treatment
elsif treatment == "off"
  # insert code here to show off treatment
  # insert your control treatment code here

The Split Ruby SDK integrates seamlessly into your code; no other changes or dependencies are needed to get Split up and running.

For more advanced configurations like running multiple evaluations at once, or using attributes in the SDK, take a look at our Ruby SDK documentation.

To continue diving into Split, sign up for a free account today, or dig into our Documentation.