Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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 (mob.example.com).

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
add comment

1 Answer

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,

#application_helper.rb
def mobile_device?
  true #put your device detection logic here
end

#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
add comment

Your Answer

 
discard

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.