Forum: Ruby on Rails rendering different html for mobile devices

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
78d56bb0f91c899d40f1767b3040d825?d=identicon&s=25 bingo bob (bingobob)
on 2009-03-05 11:50
Sorry if this is a bit OT - but I know people here like to help out!
Be grateful for any advice.

I'd like to render an html page but two versions.

- One version for mobile devices (iphones and blackberries specifically)
- One version for everything else

Any pointers appreciated.

I'd like to do this with divs on the page for each section of content
and show either depending on the viewing device.

Questions
---------

- Would this approach work?
- How do I do it?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-03-05 12:10
(Received via mailing list)
On Mar 5, 10:50 am, bingo bob <rails-mailing-l...@andreas-s.net>
wrote:
> Sorry if this is a bit OT - but I know people here like to help out!
> Be grateful for any advice.
>
> I'd like to render an html page but two versions.
>
> - One version for mobile devices (iphones and blackberries specifically)
> - One version for everything else
>

You can create 'fake' mime types for this. In a before filter you can
then set the format of the request based on the user agent. Then
instead of just having a foo.html.erb you have a foo.smartphone.erb
and foo.dumbphone.erb.

Fred
This topic is locked and can not be replied to.