Logic in views and controllers based on mobile or desktop visitor

Hi! I’m currently improving my site to be fully responsive and using media queries is a great help to change the styling for different screen sizes. But what if you want to make bigger differences in what you show to a mobile or desktop visitor? Is there a good way to do this in views and controllers? Something like:

if mobile_user?
  show something
  show something different

Hi @jarkelen,

Have a look at https://github.com/tscolari/mobylette

Rails 4.1 introduces ActionPack Variants. It allows you to specify a different layout entirely for mobile users and tablets.

I wrote a blog post about using it in a couple of months ago: http://bobonrails.com/post/72213272339/more-responsive-layouts

The rails edge guide documentation: http://edgeguides.rubyonrails.org/4_1_release_notes.html#action-pack-variants

Thanks both! As I am already on Rails 4.0.3 I go for the ActionPack Variant option by upgrading to 4.1.0 and check this out.