Josh
Josh

Reputation: 3611

How to properly configure and manage mobile site in Rails?

This post has been 'somewhat' addressed (see links at bottom of post) but not to it's full extent.

I am working on building a mobile site in Rails 2.3 (I know, I'm going to migrate to Rails 3 soon). Either way, as I continue developing this mobile site (and I am using Mobile Fu - works great), I'd like to understand best practices around configuring and managing the mobile site:

  1. Where should I redirect to the mobile domain (in application controller)? What is the best logic for doing this?
  2. Should I build the .mobile.erb files in the same folder as the .html.erb files? Or in a separate mobile folder?
  3. What kind of routes/controller/etc logic do I need for my mobile site (if I decide to not embed the mobile rendering inside my current application structure, but instead have a separate controller and mobile view folder)?

I appreciate it.

Other links: Web and Mobile views best practices same controller or namespace? http://www.arctickiwi.com/blog/mobile-enable-your-ruby-on-rails-site-for-small-screens

Upvotes: 1

Views: 478

Answers (1)

Richard Hulse
Richard Hulse

Reputation: 10493

Rather than answer your question directly, I am going to suggest that best practices have moved on somewhat.

Concepts like Mobile First, Adaptive Design, Responsive Design, and Progressive Enhancement are replacing the split site approach as best-practice.

These concepts revolve around building out your site for mobile first (so you can work out what the most important things are) and then extending the design for screens that are larger.

It removes the need to determine if it is a 'mobile' accessing the site and instead relies on various techniques (adapt.js or CSS media queries) to target different layouts to the variou screen sizes. It also means you do not have to maintain multiple views and routing - you have one view and change the CSS.

When you move to Rails 3.1 (with the pipeline) this allows the creation of CSS (and JS) manifests, and you can (potentially) have one manifest for each screen size.

There are issues with the above approach (just as there are with split sites), but if you Google the key terms above you'll find tons of advice. Best of luck either way!

Edit: Here are some links I found useful.

http://www.lukew.com/ff/entry.asp?933

http://www.netmagazine.com/features/mobile-first

http://www.alistapart.com/articles/responsive-web-design/

http://coding.smashingmagazine.com/2011/01/12/guidelines-for-responsive-web-design/

http://www.alistapart.com/articles/taking-advantage-of-html5-and-css3-with-modernizr/

http://www.sitepoint.com/regressive-enhancement-with-modernizr-and-yepnope/

There are some that think that this is bad though:

http://nefariousdesigns.co.uk/archive/2011/05/sniff-my-browser-the-modernizr-inadequacy/

Upvotes: 1

Related Questions