Hi everyone! It's Mahdi, the intern from Tunisia, again!
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!
First, let's start by installing the gem: add
gem 'jpmobile' to your
Gemfile and run
# regular phone
# smart phone
# other (computer, tablet)
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.
You can also load custom assets, or in this case CSS, by changing some parameters inside your main layout file
For example, for the case of
application_smart_phone.html.erb we change
<%= stylesheet_link_tag "application", :media => "all" %>
<%= stylesheet_link_tag "smart_phone/application", :media => "all" %>
changing the loaded CSS from
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.
Until next time!