Created
May 23, 2012 20:10
-
-
Save jmervine/2777468 to your computer and use it in GitHub Desktop.
Sinatra Mobile Detection using rack-mobile-detect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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