Today, I'm going to introduce the rails gem jpmobile and show some tips for easy configuration.

Before starting, jpmobile is a gem that allows you to adapt your rails app to the different kinds of used phones in Japan. Whether you're trying to target a specific cell operator or a specific kind of phones, jpmobile should be able to handle it all!

Separating layouts

By adding

include Jpmobile::ViewSelector

to the top of your controller, you allow jpmobile to show device-specific templates. The different templates would need to be named accordingly so that they could be automatically shown depending on the kind of device trying to load the page:

Note that this could also be applied to layouts. e.g. application_smart_phone.html.erb

Separating assets

You can also load custom assets, or in this case CSS, by changing some parameters inside your main layout file application.html.erb.

For example, for the case of application_smart_phone.html.erb we change

"all" %>

into

"all" %>

changing the loaded CSS from assets/articles.css to assets/smart_phone/articles.css !

Unfortunately, unlike the templates method, this one doesn't have a fallback: When a file doesn't exist, it won't be loaded and jpmobile won't look for similarly named files in the original stylesheets folder.

I hope this have been a helpful small introduction, do try to use it!jpmobile is really powerful and flexible making it a really good choice for incorporating device-specific content.