Include it in your application.rb like so:
module ModernizrTestApp class Application < Rails::Application config.middleware.use :: end end
or in your config.ru:
# Initialize the rails application MyApp::Application.initialize! # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) require 'modernizr' # WARNING: session storage is not working properly with config.ru initialization :/ use :: run MyApp::Application
In your rails code, Modernizr's client side detected browser functionality is now available from the Rack environment. (w00t!)
<%= request.env['X-rack-modernizr'].inspect %>
if 1==request.env['X-rack-modernizr']['video']['h264'] # do stuff end
Rack-modernizr chews up 1k of cookie data (yikes!). If you are storing session data in the database or memcache, you can avoid the cookie tax by pushing modernizr data into the session:
module ModernizrTestApp class Application < Rails::Application config.middleware.use ::, :storage => "session" end end
(in no particular order)
- Cool kid .accessorize method, like rack-flash.
- Better unit testing for sessions and cookies.
- Rails helper to clean up retrieval syntax
- compression to cut down on 1k cookie storage size