dace
dace

Reputation: 6363

Is there a way to display different content on mobile vs. desktop in Rails?

I have a rails app that uses bootstrap. It's meant to be used on mobile (it focuses heavily on geolocation from your phone's gps). I want to make the app accessible if you visit from your mobile device, but if you visit from your desktop/laptop/tablet, a message should appear stating that it's only meant for use on phones. Is this possible to do in Rails? Thanks!

Upvotes: 0

Views: 713

Answers (1)

Mike S
Mike S

Reputation: 11409

Yes.

Mobile Fu is a rails gem that allows you to do this. You just need to check if the request is from a mobile device and subsequently render whatever you want to based on that. If you're on Rails 4 this might be helpful too.

Upvotes: 1

Related Questions