Sinatra Mobile Dection - rack-mobile-detect

I was looking for a simple way to detect mobile devices for this blog, a Sinatra application, and found rack-mobile-detect.

Gemfile:
gem 'rack-mobile-detect'
config.ru:
require '<other stuff>'
require 'rack/mobile-detect'

# ... other config.ru stuff ...
use Rack::MobileDetect
# ... other config.ru stuff ...
app.rb:
require 'sinatra'
helpers do
  def get_layout
    @layout_default = ( request.env['X_MOBILE_DEVICE'] ? :layout_mobile : true )
  end

end

before do
  get_layout()
end

get "/" do
  erb :index, :layout => @layout_default
end