Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

To note, I'm not interested in simply 'hiding' content for mobile devices, I want to filter out that content completely. I'm also not trying to address the issue by building a mobile specific interface (

There was another question regarding something similar:

How do I prevent useless content load on the page in responsive design?

The solution, in that post, was to set a session during the initial request, and then use the session to filter content on subsequent requests.

I primarily develop in Rails, and I'm wondering if there are any gems or ruby-specific solutions to this problem?

share|improve this question

by 'fiter out completely' do you mean that you just don't want to pass the content to client and hide them using CSS? if so, in your rails views why don't you take output decision based on the device? for example,

def mobile_device?
  true #put your device detection logic here

#view file (in haml)
- if mobile_device?
  Mobile content
- else 
  General content

instead of using your device detection logic, you can also use useragent gem

you can also render completely different view/partial depending on the browser/device.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.