Skip to content

Instantly share code, notes, and snippets.

@jmervine
Created May 23, 2012 20:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmervine/2777468 to your computer and use it in GitHub Desktop.
Save jmervine/2777468 to your computer and use it in GitHub Desktop.
Sinatra Mobile Detection using rack-mobile-detect
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
require '<other stuff>'
require 'rack/mobile-detect'
# ... other config.ru stuff ...
use Rack::MobileDetect
# ... other config.ru stuff ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment