Meltemi
Meltemi

Reputation: 38359

Rails 3.1+ way to serve both mobile & desktop clients

What the going "best practice" for serving both mobile & desktop browsers from a Rails application?

I'm not talking about custom apps on the mobile side but, mainly (entirely?!?), mobile Webkit.

I watched Railscast 199 which shows a technique of rendering and returning different views depending on whether the browser is mobile or not. Wondering if this is still preferable? What about just offering different CSS (assuming the content is largely the same)? Ideally the solution could take advantage of one of the mobile JQuery libraries (JQuery Mobile, JQTouch, Sencha Touch, etc.) How would things be handled through the asset pipeline?

Upvotes: 3

Views: 935

Answers (2)

Forrest
Forrest

Reputation: 1095

Mobile_fu is still a great way to do it.

You'll need a separate layout file. For my apps which serve up both versions, I have separate JS and CSS folders at /assets/application & /assets/mobile.

I've had good luck with JQuery Mobile, but I've heard good things about Sencha too so that's probably personal preference.

Upvotes: 1

Limbo Peng
Limbo Peng

Reputation: 2505

Since you mention mobile Webkit, I think using CSS3's media query to adapt various devices would be a good choice. Here are some blog posts that are related:

  1. Responsive Design with CSS3 Media Queries

  2. How To Use CSS3 Media Queries To Create a Mobile Version of Your Website

Upvotes: 1

Related Questions