This code repo contains no business logic, only serves as a demo to integrate split.io Ruby SDK with Rails.
- Ruby, here I use version 2.7.5 for an example (can install via a Ruby version manager, recommend
asdf
) - Httpie for CLI testing (feel free to use cURL / Postman)
- run
bundle install
to install Ruby dependencies (split.io Ruby SDK already included)
- run
SPLIT_IO_API_KEY=xxx rails s
in command line to start a web server process on your computer, replacexxx
with your server-side split.io API key - run
SPLIT_IO_API_KEY=xxx rails c
in command line to start a Rails console process on your computer, replacexxx
with your server-side split.io API key
In command line interface, run http localhost:3030
to check if the server is running, expecting response { "ok": true}
-
on split.io dashboard, create a split named
test_global_feature_flag
, traffic type can beglobal
oraccount
-
define treatment
on
andoff
, configure theSet the default rule
to serveoff
-
run
http 'localhost:3030/test_global_feature_flag'
in command line, response should be{"ok": true, "status": "off"}
-
In Rails console, run
SPLIT_CLIENT.get_treatment('global', 'test_global_feature_flag')
, result should beoff
-
on split.io dashboard, change default rule of split
test_global_feature_flag
fromoff
toon
-
run
http 'localhost:3030/test_global_feature_flag'
in command line, response should be{"ok": true, "status": "on"}
-
In Rails console, run
SPLIT_CLIENT.get_treatment('global', 'test_global_feature_flag')
, expected result ison
, actual result isoff
. SDK data is not syned!
- In Rails console, after running
Rails.configuration.split_factory.resume!
, it seems the SDK in Rails console process starts to sync data with split.io web service.