DEV Community

Andy Huynh
Andy Huynh

Posted on

3

wtf is a feature flag?

bulldozer

rollout.io
optimizely.com
launchdarkly

The above services are bulldozers for many applications. Large companies rely on their added features like shiny dashboards and sugar methods.

Andy's dictionary:

Feature flag: allows your system to conditionally show a feature to a customer.

Feature flags are an abstraction on top of your basic programming conditionals. They house the logic of your underlying features a customer should or should not be able to access.

Imagine a scenario where you're wrapping up a feature for your SaSS. It's ready to go, however - you'd be more confident if a few customers can test it out.

More or less... beta testing.

The above services can prove to be hefty for smaller projects. You might not have many users yet. Your codebase might not be the size of an enterprise. Did I mention those services are mostly bulldozers? Where the shovel at?

I got your shovel. Integrating feature flags to Ruby projects can be accomplished using Rollout. It's minimal in it's approach and reads well. It doesn't hurt that the project has few outstanding Github issues in it's queue.

Rollout also scales well. Kajabi has a generous user base. We're releasing features non stop! We've built features on top of Rollout for our needs and it's still in use, today.

Back to our contrived example, let's say you're adding an affiliate program. You have a founders group and want to ensure they get their hands on it, first!

After installing the gem, define/activate your group and use conditionally write your markup like so:

# config/initializers.rb
$rollout.define_group(:founders) do |user|
  user.plan_name == "founder"
end

$rollout.activate_group(:affiliate_program, :founders)
Enter fullscreen mode Exit fullscreen mode
<!-- index.html.erb -->
<html>
  <body>
    <% if $rollout.active?(:affiliate_program) %>
      <%= render "affiliate_program" %>
    <% else %>
      <%= render "something_else" %>
    <% end %>
  </body>
</html>
Enter fullscreen mode Exit fullscreen mode

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay