# Rendering different html for mobile devices

**URL:** <https://www.ruby-forum.com/t/rendering-different-html-for-mobile-devices/162065>\
**Category:** Rails\
**Created:** [March 5, 2009, 11:50am UTC](https://www.ruby-forum.com/t/rendering-different-html-for-mobile-devices/162065 "2009-03-05T11:50:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [March 5, 2009, 11:50am UTC](https://www.ruby-forum.com/t/rendering-different-html-for-mobile-devices/162065/1 "2009-03-05T11:50:49Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [March 5, 2009, 12:10pm UTC](https://www.ruby-forum.com/t/rendering-different-html-for-mobile-devices/162065/2 "2009-03-05T12:10:53Z")

</div>

On Mar 5, 10:50 am, bingo bob [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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
