SDKs

Ruby SDK

4 min read

Use the Ruby SDK to initialize FlagPilot, evaluate flags, pass target users, and handle fallback behavior in production.

Installation

Terminal
gem install flagpilot

Initialization

app.rb
require "flagpilot"

flagpilot = FlagPilot::Client.new(
  api_key: ENV["FLAGPILOT_SECRET_KEY"],
  environment: "production"
)
flagpilot.initialize_client

# Evaluate a feature flag
enabled = flagpilot.evaluate("checkout-redesign", current_user.id)

if enabled
  # Serve new checkout experience
end

Evaluating a flag

app.rb
enabled = flagpilot.evaluate("checkout-redesign", "user_123")

Target users

Send stable opaque user IDs and optional attributes to keep percentage rollouts and targeting rules consistent.

app.rb
flagpilot.evaluate("checkout-redesign", "user_123")

Error handling

Use a conservative fallback value when evaluation fails or the SDK cannot reach its configured source.

Best practices

  • Reuse one SDK client instance per app runtime.
  • Set the SDK environment option to development, staging, or production.
  • Hash or pseudonymize sensitive user identifiers before sending them to evaluations.

FAQ

How does Ruby SDK interact with local caches?

Configurations are synced down using Edge Config or fallback REST triggers. The client automatically reads evaluations in-memory, resulting in sub-millisecond local evaluation times.

Where can I obtain support for Ruby SDK?

You can open a support ticket in your dashboard, check the community roadmap, or consult the FlagPilot Platform Status page.

Was this page helpful?