When building a new feature into a web app, it’s useful to have beta testers use it for a a while before it’s fully launched in order to catch any last minute bugs, to get an idea of whether the new feature feels right and if it actually solves the original problem.

It is also sometimes desirable to have the beta testing process work from within the existing production app, in order for the production data to be used, and to prevent beta users from being isolated from other users. This may not be the case with an application that does not promote interaction between users, and in such cases, it is probably desirable to create a beta deploy of the application.

The following is the method by which I beta test features in my own (Rails) apps – YMMV.

Give certain users beta status

This is fairly simple – either add a boolean beta field to the user model or, if you’re using something to manage roles, add a beta role to the users you’re adding to your beta program. Be sure to protect this attribute:

attr_protected :is_beta

If you’re using roles, then you can segment your beta users, granting access to individual features if necessary.

Hiding actions fron non-beta users

In your application_controller.rb define the following function:

def require_beta
  @current_user.is_beta?
end

In any controllers that have actions that need to be protected, you can then write:

before_filter :require_beta

Hiding UI elements

There will probably be links, forms and UI elements that you’ll need to only display to beta users, so, in your application helper:

def beta(&block)
  yield(block) if current_user.try(:is_beta?)
end

def non_beta(&block)
  yield(block) unless current_user.try(:is_beta?)
end

Then, whenever you have a UI element you only want to appear to beta users, just wrap it in the beta call:

<% beta do %>
  This text will only be shown to logged in beta testers
<% end %>

<% non_beta do %>
  This text will only be shown to normal users and non-logged in users
<% end %>