Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6168861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:45:36+00:00 2026-05-23T22:45:36+00:00

I am looking into the methods of styling a Rails app for mobile use.

  • 0

I am looking into the methods of styling a Rails app for mobile use.

The idea is common, using one set of styles for mobile browsers and another set for traditional.

From what I can tell there are two basic ways of doing this in Rails:

Using a helper method to detect the user agent and then preform the switch.

application_controller.rb

 private  
 def mobile?  
   request.user_agent =~ /Mobile|webOS/  
 end 

 helper_method :mobile?

application.html.erb

<% unless mobile? %>
 <%= stylesheet_link_tag "core" %>
<%else%>
  <%= stylesheet_link_tag "mobile" %>
  <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<% end%>

Or using media queries in the style sheets

body {
// basic styles
}

@media all and (max-width: 600px) {
 body {
 // extra styles for mobile
 }
}

@media all and (min-width: 600px) {
 body {
  // extra styles for desktop
 }
}

My question is what are the trade offs? Is one method generally better or are there good use cases for both.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:45:37+00:00Added an answer on May 23, 2026 at 10:45 pm

    It depends.

    On my personal website I use media queries to change the styles for mobile browsers. This works pretty well in this case because the page has very few images and the majority of style changes are just to make the website vertical and shrink font sizes.

    Unfortunately, however, not every mobile phone understands media queries. Further, depending on what you’re doing with your media queries, you may be sacrificing performance by using media queries. For example, shrinking the display of big images, or hiding content negatively affects performance in network constrained mobile phones.

    For complicated websites, you may also want to render completely different websites to customize the mobile experience. Using the “helper” approach allows you to customize more than just the stylesheet. This also allows mobile users to access the “normal” website on their phone by passing an additional parameter that is taken into account in your mobile? method.

    In summary : If it’s simple, media queries are an easy way to customize display, however the mobile experience is likely going to be more holistically different than just minor display tweaks. Trying to use CSS to customize the entire experience isn’t a good idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking into strong typed Windows Forms databinding using extension methods. I have
I'm looking into creating a simple iPhone app without using the interface builder, i.e.
I'm looking into a restful design and would like to use the HTTP methods
I am looking into methods to inject javascript into any webpage loaded in the
I'm looking into the various methods of rate limiting the Django admin login to
I'm looking into providing several methods of visualizing a large volume of data. This
In my custom view I'm looking into using Canvas.getClipBounds() to optimize my onDraw method
I have been looking into communication methods between two iPhone devices and as I
Using .Net 4.0 and SQL Server 2008 R2 I have been looking into utilizing
So, I've started looking into using AspectJ to handle processing events when the state

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.