# Mobile version

**URL:** <https://www.ruby-forum.com/t/mobile-version/143647>\
**Category:** Rails\
**Created:** [July 21, 2008, 3:03pm UTC](https://www.ruby-forum.com/t/mobile-version/143647 "2008-07-21T15:03:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![matte\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@matte\_S](https://www.ruby-forum.com/u/matte_S)\
**Post date:** [July 21, 2008, 3:03pm UTC](https://www.ruby-forum.com/t/mobile-version/143647/1 "2008-07-21T15:03:04Z")

</div>

Hi, I am building 3 layouts of the same site: 1 for the web, 1 for the  
iphone, 1 for the mobile (xhtml mp). I know if the request of my site is  
from iphone with this string:

request.env[“HTTP\_USER\_AGENT”] &&  
request.env[“HTTP\_USER\_AGENT”][/(Mobile/.+Safari)/]

How can I know when the request is from mobile or (in fact the same  
result) is from internet web browsers?

Matteo.

---

<div class="post-metadata">

**Author:** ![matte\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@matte\_S](https://www.ruby-forum.com/u/matte_S)\
**Post date:** [July 21, 2008, 3:45pm UTC](https://www.ruby-forum.com/t/mobile-version/143647/2 "2008-07-21T15:45:38Z")

</div>

Have you searched the web for the user agent strings of the most  
common mobile phones that have web capabilities to see if there is  
some common string to can key off of?

---

<div class="post-metadata">

**Author:** ![matte\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@matte\_S](https://www.ruby-forum.com/u/matte_S)\
**Post date:** [July 21, 2008, 4:02pm UTC](https://www.ruby-forum.com/t/mobile-version/143647/3 "2008-07-21T16:02:06Z")

</div>

Okay. After a quick search it appears the detection of mobile devices  
is somewhat non-trivial. Solutions extend from building arrays of  
“common” user agent strings for various mobile devices through the use  
of comprehensive XML files containing information about the  
capabilities of mobile devices. Here’s is an example of one I was able  
to find:

> **[WURFL - Mobile Device Database by ScientiaMobile](https://wurfl.sourceforge.net/)**
>
> WURFL, by ScientiaMobile, is a DDR (Device Description Repository), a catalogue of mobile device information and a framework for adaptation of mobile applications

There are other examples that may do the trick for the more common  
mobile devices. But, there appears to be no consistent string that  
guarantees whether the device is mobile or not. At least not that I  
have found in my quick search.

---

<div class="post-metadata">

**Author:** ![matte\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@matte\_S](https://www.ruby-forum.com/u/matte_S)\
**Post date:** [July 21, 2008, 4:19pm UTC](https://www.ruby-forum.com/t/mobile-version/143647/4 "2008-07-21T16:19:12Z")

</div>

> [http://wurfl.sourceforge.net/](http://wurfl.sourceforge.net/)

I think this is the best solution. I think to keep the list from the  
file and check the user\_agent.  
Thank a lot!  
M.

---

<div class="post-metadata">

**Author:** ![matte\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@matte\_S](https://www.ruby-forum.com/u/matte_S)\
**Post date:** [July 21, 2008, 4:04pm UTC](https://www.ruby-forum.com/t/mobile-version/143647/5 "2008-07-21T16:04:15Z")

</div>

Robert W. wrote:

> Have you searched the web for the user agent strings of the most  
> common mobile phones that have web capabilities to see if there is  
> some common string to can key off of?

Yes, I searched for mobile device user agent and I found just single  
user agent list like this:

> **[Mobile::UserAgent - mobile user agent string parsing class - metacpan.org](https://metacpan.org/release/CMANLEY/Mobile-UserAgent-1.05/view/lib/Mobile/UserAgent.pm)**
>
> mobile user agent string parsing class

But I hope to find a code for detecting all mobiles request instead to  
create a long list to manage. I think this is more useful.

---

<div class="post-metadata">

**Author:** ![matte\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@matte\_S](https://www.ruby-forum.com/u/matte_S)\
**Post date:** [July 21, 2008, 4:46pm UTC](https://www.ruby-forum.com/t/mobile-version/143647/6 "2008-07-21T16:46:58Z")

</div>

If it helps I found also this resource:

[http://www.useragents.org/database-useragents.asp](http://www.useragents.org/database-useragents.asp)

Is in italian but there are common links like browser, robots, sistema  
operativo (os).  
And there is a rss:  
[http://www.useragents.org/database-useragents.asp](http://www.useragents.org/database-useragents.asp)
