- the problem : how to serve different view templates to their hybrid mobile apps and desktop clients at the same time?
- the solution: introduce a new feature to Rails. One that will enable single action to serve different templates.
- conceptually: "variant" is a symbol whose name constitutes a part of the variant naming scheme
- naming scheme is: action_name.html+variant_name.erb -> new.html+mobile.erb
- technically: a symbol, or an array of symbols, that get assigned with a call to request.variant=
- use request.user_agent to test the client type
- if no "variant template" is found, the default action template gets rendered
- it works for partials just the same
browser gem
- it exposes browser object to the ActionController
- transparent API:
- browser.chrome?
- browser.bot.search_engine?
- browser.device.mobile?
- browser.platform.linux?