Hello Ryan,
Thanks for another great cast!
Luciano
Thanks Ryan! I am always a fan of your succinct presentation of useful information. On a side note, I have been playing around with http://www.appcelerator.com/ for making iPhone apps quickly and (dare I say it) easily. Let me know if you've used it. I'd love to hear your thoughts!
Adam
Ryan, you timing could not have been better. Customizing one my apps for mobile devices is my project of the week and I did not not about JQTouch so that's great.
The rest of the screencast is very helpful too, I will use your mobile_device? method instead of messing with the cumbersome WURFL file and its conversion to MySQL.
Thanks again and have a great week.
That screencast was totally awesome. When I saw the title I thought that I would knew everything that you could possibly show in this screencast... but apparently I was wrong, I learned many things. Thank you very much again! :)
Risking repeating what others have said, this is exactly what I was looking for. Can't believe the good timing.
For the shake of completeness: I think today's post is missing the contents of the mobile.js file (even if it's just one line, for initializing jqtouch)
Thanks again!
As ever high-quality screencasts in the right moment!
Thanks!
I was just wondering how to pull this off. I'm guessing some clients probably want a mobile version for their site and so I'm glad you posted this because I was clueless earlier.
Thanks for the great cast! as usual.
I'd like to introduce the ActiveDevice (http://github.com/shenoudab/active_device), Our Rails Gem and Plug-in for Device Detection (Mobile, Desktop Browser, Bot). with many helper methods for checking and detect the Mobile Brand, Model, Engine and others ..
Very cool, good work as always - Brendan Lim's mobile fu is a good solution here as well:
http://github.com/brendanlim/mobile-fu
@Adam King - agreed, Appcelerator Titanium rocks! If you're interested in doing a native app with web tech, check it out.
Hello Ryan,
Can you add url to list
http://github.com/brendanlim/mobile-fu/ ?
Automatically detect mobile requests from mobile devices in your Rails application
Great cast Ryan. I noticed that you created a mobile-format version of every view file... is there an easy way to tell Rails to automatically default to the HTML version if a mobile version of the view doesn't exist? I have tons of views in my app, and the truth is that only some sections of the app really need special mobile treatment and I don't have the time to make ".mobile.erb" files for every view. If I don't create a mobile version of a specific view, then I get a "Template is missing" error that says that "index.erb" does not exist (for example).
Great cast, note that you could also use the Android simulator to check the looks, especially since Android is growing rapidly on the web!
Emulator is available through Google: http://developer.android.com/guide/developing/tools/emulator.html
@egarcia, thanks! Added.
@Matt, good question. I looked into this briefly but did not have enough time to fully investigate it. The register_alias method has a 3rd argument called extension_synonyms which I was hoping would do this but I could not get it to work. If you do find a solution please let me know!
Wow great stuff Ryan!
The web app (instead of native iphone app) looks like a good options for a few reasons:
1. you can keep all your code under one project (easier to manage over time as you add/remove features)
2. Don't have to go through Apple's review process
Does that seem accurate in your experience? Thanks for your great work!
you can change your useragent in firefox too, using this plugin: https://addons.mozilla.org/en-US/firefox/addon/967
although this is not as convenient as the drop-down list in safari, it still works :)
As a mobile device and desktop user, I'm a bit concerned about your approach - you're basically returning different content for the same URL, depending on whether I come from a mobile phone or a desktop, aren't you?
Wouldn't it be better to redirect mobile users to a different URL, and serve consistently cachable content from the same URL?
Mapping URL:content on a 1:1 basis is the RESTful way of doing things. That way I could access the "desktop" version of the site from a if I so wished, or the mobile version from the desktop - all without changing the way the site behaves for me normally.
@Brian, yeah, those are two great benefits to building a web app over a native app. And it is fairly easy to port across mobile platforms.
Just be aware of the negatives too. User must be online and app has limited access to hardware (camera, accelerometer, multi-touch, etc.). I have seen ways to do offline caching with jQTouch but haven't tested it.
@Alex, that's a great point. I was considering doing this with a subdomain but it was too much to cover in this episode. I do recommend using a subdomain though. The nice thing is, if you build your site around the "mobile_devices?" method, it is very easy to swap out the behavior depending on subdomain, user settings, etc.
Ryan, how do you manage page caching with this technique?
Wow, you never disappoint me. I watch your screen casts every monday, and I feel like each week my career is really bolstered by the knowledge I gain from them.
Thank you.
@Juan, for page caching I recommend using a subdomain or something in the routes to separate the mobile version from the full version. See my response to Alex earlier.
wow, almost two hundred episodes and you still impressing me every f***ing time, thanks!!
Please more Railscasts
saw them all and I can't get enough..
Thank you very much !! That's exactly what I was looking for
Hi Ryan
I created a blog with similar information recently:
http://www.arctickiwi.com/blog/2-mobile-enable-your-ruby-on-rails-site-for-small-screens
This just uses a different application layout if the device is detected to be mobile.
Cheers
Hi Ryan,
Thanks for this episode (as well as all the others).
At the beginning of the episode, you touched on the notion of browsing your development app through a mobile device. I've run into a little problem with this that's probably an obvious fix. When I try to hit my local dev app from any machine other than the computer that is running the dev app, none of the assets, such as stylesheets and javascript, load. When I look at the html, I see that "localhost:3000" is embedded in the urls for those assets. What should I change to make this work properly?
My current dev setup is:
- Mac OS X 10.6
- Rail 2.3.5
- start dev app using "script/server" which uses mongrel
Thanks!
This is a little modification for auto detect. If someone find useful:
before_filter :ready_for_mobi
private
MOBILE_BROWSERS = ["android", "ipod", "opera mini", "blackberry", "palm","hiptop","avantgo","plucker", "xiino","blazer","elaine", "windows ce; ppc;", "windows ce; smartphone;","windows ce; iemobile", "up.browser","up.link","mmp","symbian","smartphone", "midp","wap","vodafone","o2","pocket","kindle", "mobile","pda","psp","treo"]
def ready_for_mobi
agent = request.headers["HTTP_USER_AGENT"].downcase
MOBILE_BROWSERS.each do |m|
return request.format = :mobile if agent.match(m)
end
end
Como sempre mais um screencast fabuloso! Parabéns Ryan.
Congratulations for this fantastic screencast Ryan!
@Alex, @Ryan (Comments #19 & 20)
According my understanding of the RFC2616 (sections 14.14, 13.6 mostly), HTTP/1.1 allows you to serve multiple content variants of the same resource URL and have the cache layers working fine, thanks to the Content-Location and ETag headers.
Here's how I understood it works:
When serving a resource (let's say /resource/1) with a particular content variant, you specify this chosen variant's URL (/resource/1.html for "desktop" variant and /resource/1.mobile for the mobile one) with the Content-Location header and send the corresponding ETag.
When a cache layer is requested for that resource again, it will query the server with all the variants' ETag it knows (If-Match header) and, depending on whether one of the provided ETag corresponds to the actual resource variant to be served, the server sends a "304 Not Modified" answer with the corresponding Content-Location so the cache knows what content variant to send to the client.
However Rails does not seem to be currently ready for such behaviour (no signs of a Content-Location header in the sources for instance, except in the tmail library bundled with actionmailer) so yes, the best thing to do is to either use a subdomain and/or redirect the mobile and/or the desktop client to their corresponding variant (with a ".:format" extension,) thanks to the :format option of the url_for (and alike) helper methods.
Beyond useful... Thanks.
I've been looking for a simple way to get into the mobile domain.
@myself (Comment #33) and everyone interested about the caching subject:
There is also the Vary header that can help to provide multiple content variants of the same resource URL.
See sections #14.44 & 13.6 of RFC 2616, or for the explanations about "Caching and Alternates" and the "Vary header" pp.401 to 403 of the "HTTP: the Definitive guide" (if you don't have this book, those pages are part of the preview available online at oreilly.com: http://oreilly.com/catalog/9781565925090/preview) Figure 17-2 illustrates the "Vary: User-Agent" mechanism.
The Vary: header method is Rails compatible out of the box (simply use "headers['Vary'] = 'User-Agent'" where needed), but it is not very efficient for the shared caches that sit between the clients and the server as they will have to keep one cache entry per existing User-Agent string...
i played around with jqtouch and i was not impressed. iwebkit (http://iwebkit.net/) is much cleaner in all concerns: markup, capabilities, ui and documentation.
Great Cast! If you are interested in building an actual iPhone App, I recommend ObjectiveResource which is an Objective-C port of Ruby on Rails' ActiveResource. check it out at http://iphoneonrails.com. I'm still looking for an Android library that does the same.
Thanks Ryan, this method just solve my idea of building mobile integration onto my project...
anyway, anyone still have the src for those old episode... especially on the sub domain episode...
Thanks for the great cast. This will really help.
I was impressed by how much jQTouch did. Have you heard of any prototype based libraries that perform similar tasks?
Great as always.
I'd like to see more about jQTouch.
Thanks.
Hi, mobile devices often comes in different screen dimensions and capabilities, therefore you may need to render images that are optimized for a specific screen dimensions to maximize user experience. WURFL (http://wurfl.sourceforge.net/) is a powerful library that allows you to query and determined the characteristic of a mobile device from screen dimension to features and capabilities of mobile devices. The device list is update frequently from people around the world. There is a ruby version of it.
Thanks Ryan for covering this!!!! Perfect timing, pretty helpful for tomorrow :)
Hello - just in case anyone else working on a mobile app ran into the same problem I did where your dev env creates asset URLs with "http://localhost:3000/" (see comment #29) - here's how I got around the issue:
I added the following to my config/environments/development.rb:
config.after_initialize do
ActionController::Base.asset_host = ''
end
Hope that helps!
@Alex, @Ryan, @Juan, @Frederic:
I have managed to separate caches for mobile and normal browsers. I do most of the work in .htaccess fils. So you should serve your application under Apache. The solution is super easy. You can review it at
http://www.badrit.com/blog/2010/2/2/keeping-separate-caches-for-mobile-browsers
--
Ahmed ElDawy
www.badrit.com
Thx for this nice screencast!
I like the JQTouch Interface Plugin with Themes. Is there a similar solution for standard web apps? I mean a comparable css theme that makes developing Web-GUIs easier by suppling nice features like buttons and so on?
Is there something you can recommend?
Hmm maybe I'll just have to stick with jQueryUI.. But jQTouch seems to do more...
How do you deal with page caching when you have mobile views???
Hey Brian, are you aware that the video controls for your videos don't work in Chrome? Just fyi.
Great info here! I've been using iUI for a while, but I do like how you have this one set up.
Has anyone found any clever CSS to handle the errorExplanation div for mobile devices? It doesn't seem to stand out as much to me. I'll have to play a bit more with it. Any best practices when it comes to displaying errors in a mobile web app with rails?
Thanks for the great screencast Ryan! I made a little modification to distinguish JavaScript from HTML (or other) requests. That way you can respond nicely to AJAX requests on a mobile device (for example jQT.goBack() after a submitted form).
if mobile_device?
if request.format == :js
request.format = :mobilejs
else
request.format = :mobile
end
end
http://gist.github.com/308804
Anyone had a issue using jqtouch whereby your mobile views (as created above) continuously reload in an infinite loop? I tracked it down to the setting of location.hash in jqtouch.js on line 189 (beta 2), but I'm not sure of the underlying reason.
@LW, yep, I've run into the same issue.
I also ran into an issue on Rails 3 where the AJAX requests load the full HTML page, but don't replace the whole page. So you end up with
<html>
...
<body>
<html>...</html>
</body>
</html>
Which is obviously wrong. So looks like this screencast might be a bit out of date or didn't take that into account :-(
You have to set the top-level DIV id attribute to "home" (just giving it class of "current" is not enough). This is valid for the Beta 2 version of jqtouch. I saw the infinite loop issue on Jaunty with FF 3.0.x... that was painful to track down given that there are very few good examples for jqtouch (even the oreilly iphone book with the jqtouch example doesn't show the id attribute).
Great introduction into developing for mobile Ryan. I had been looking for a tutorial like this one for a while! Except I am running into some issues.
I am trying to replicate your tutorial on an existing rails app. Everything looks fine until you try to load the show.mobile.erb. Instead of being loaded into the current page in the mobile layout, it just loads in as is. Any idea why it would be disregarding the layout?
Thanks in advance for any help you can offer.
I liked the quick snap. Super cool cast. Thanks Ryan!
how do you set the id of linked pages loaded in by jqtouch via ajax? for each transition, jqtouch loads in the page successively as:
<div class="current slide in " id="page-3">
<div class="current slide in " id="page-8">
<div class="current slide in " id="page-13">
thanks,
mark
Great screencast, but having an issue.
Using this setup, ALL major browsers work just fine, switching between mobile and full without issue, except IE8, which will shows the full site on the home page, but switches to the mobile site for all other pages, clicking the "fullsite" button does not help.
Debugging shows IE was passing the following as the request.format:
#<Mime::Type:0x103699f48 @synonyms=[], @symbol=nil, @string="image/jpeg">
added this to a before filter that runs before prepare_for_mobile and all is good...but feels lame.
Anyone else have this issue with IE8 and this setup
forgot...this is the "this" in my post:
request.format = :html if request.format == "image/jpeg"
Ryan thank you so much for your work :)
I'm working on windows XP and I had problem accessing http://'mycompname'.local:3000/
with http://'mycompname'.local/ I don't have any problems.
Anyone have idea how to solve it?
ou man.., I’ve never seen an article like this.
It was very nice reading it.
railscasts is awesome!
keep up the good work, I’ll definitely come back to railscasts!
Hi..Your post is amazing. From long time I search for this information. But I didn’t get right thing. Thanks to you I got stuff which I am looking for. I would like to read more from you.
Your post is rocking and knowledgeable... I really appreciate the way you write . I would like to read more from you.
Ou man.., I’ve never seen an article like this. It was very nice reading it. Railscasts is awesome! Keep up the good work, I’ll definitely come back to railscasts!
Using this setup, ALL major browsers work just fine, switching between mobile and full without issue, except IE8, which will shows the full site on the home page, but switches to the mobile site for all other pages, clicking the "fullsite" button does not help.
Thanks for the nice post. I am expecting some different idea from your side. You always represent some new thought in your post.
hey buddy,this is one of the best posts that I’ve ever seen; you may include some more ideas in the same theme. I’m still waiting for some interesting thoughts from your side in your next post.
This is one of the best posts that I’ve ever seen; you may include some more ideas in the same theme. I’m still waiting for some interesting thoughts from your side in your next post.
Change the look and behavior of a Rails app on mobile devices. Also use jQTouch to build a native-looking interface
Great article! I really love the second paragraph, I know exactly what you mean! This site is great thanks again!
Corey
These railcasts are fricken amazing! I cant get enough hahaha
Corey
Cheers for the blog and sharing the information. It is really helpful.
I like to share other people's happiness, as your article is really nice
I was looking for something similar like this. Thanks for this useful information.
I am accomplishing analysis plan in the acreage of solar energy. I charge digital abstracts of all-around solar radiation of Nepal. If accessible amuse accommodate us for added analysis or informations.
I am accomplishing analysis plan in the acreage of solar energy. I charge digital abstracts of all-around solar radiation of Nepal. If accessible amuse accommodate us for added analysis or informations.
Thanks a lot for enjoying this beauty article with me. I am apreciating it very much! Looking forward to another great article. Good luck to the author! all the best!
Our discount shop sale many things, such as shoes,cloth, jerseys ect.They will give you an unexpect surprise.Welcime you come to visit them in our discount shop.Our site is http://www.goecshop.com
I was actually looking for this resource a few weeks back. Thanks for sharing with us your wisdom.This will absolutely going to help me in my projects .
I am very interested in this topic, I think it is very good
I like your blog,and also like the article,and thank you for provide me so much information :))
i still have a 2003 nokia phone, lmfao, so this isn't all too apt to me.
Thanks for sharring importent information in this blog.
I was looking for information similar to this one...and m really happy that I got it here atlast...checked your website and the product recommended by you...thnaks for the information...
I am apreciating it very much.I have never read such a lovely article and I am coming back
tomorrow to continue reading.
thank for good information.
Thanks for sharring importent information in this blog.
i like this post and help me to learn i appreciate this effort.
it is so useful to me.
thanks for your share.i will see next time,looking for your next article.
maybe you can see<a href="http://www.poloshirtsb2c.com/lacoste-polo-shirts-womens-lacoste-polo-c-2_10.html">womens lacoste polo</a>it is so useful to me.
I really liked this post as it is quite informative without any filler content. Looking forward to more such posts in future. Excellent post.
Ryan, how do you manage page caching with this technique?
Great job here. Keep the great posts coming. I follow your blog.
I duoble that! how do you manage page caching with this technique?
A mobile device (also known as a handheld device, handheld computer or simply handheld) is a pocket-sized computing device, typically having a display screen with touch input and/or a miniature keyboard. In the case of the personal digital assistant (PDA) the input and output are often combined into a touch-screen interface. Smartphones and PDAs are popular amongst those who require the assistance and convenience of certain aspects of a conventional computer, in environments where carrying one would not be practical. Enterprise digital assistants can further extend the available functionality for the business user by offering integrated data capture devices like barcode, RFID and smart card readers.
Handheld devices have become ruggedized for use in mobile field management situations to record information in the field. They are used to achieve a variety of tasks for increasing efficiency that include digitizing notes, sending and receiving invoices, asset management, recording signatures, managing parts and scanning barcodes. Handheld computers used at work have molded over time into a variety of form factors, including smartphones on the low end, handheld PDAs, Ultra-Mobile PCs and Tablet PCs. Laptops do not come under handheld computers as they are not small enough to hold in one's hand.
A personal digital assistant (PDA), also known as a palmtop computer, is a mobile device which functions as a personal information manager and has the ability to connect to the internet. The PDA has an electronic visual display enabling it to include a web browser, but some newer models also have audio capabilities, enabling them to be used as mobile phones or portable media players. Many PDAs can access the internet, intranets or extranets via Wi-Fi, or Wireless Wide Area Networks . Many PDAs employ touch screen technology.
Currently, a typical PDA has touch screen for entering data, a memory card slot for data storage and at least one of the following for connectivity: IrDA, Bluetooth and/or WiFi. However, many PDAs (typically those used primarily as telephones) may not have a touch screen, using softkeys, a directional pad and either the numeric keypad or a thumb keyboard for input.Software typically required to be a PDA includes an appointment calendar, a to-do list, an address book for contacts and some sort of note program. Connected PDAs also typically include E-mail and Web support.
Although many early PDAs did not have memory card slots now most have either an SD and/or a Compact Flash slot. Although originally designed for memory, SDIO and Compact Flash cards are available for such things as Wi-Fi and Webcams. Some PDAs also have a USB port, mainly for USB flash drives. Some PDAs are now compatible with micro SD cards, which are physically much smaller than standard SD cards.
I really liked this post as it is quite informative without any filler content. Looking forward to more such posts in future. Excellent post.
Thanks for the info. I just followed you on Twitter cause of this post.
I really liked this post as it is quite informative without any filler content. Looking forward to more such posts in future. Excellent post.
I agree. Sometimes the less you know the better off you are....quote from a Bob Seger song "wish I didn't know now what I didn't know then"...and I was much happier as a kid, more ignorant for sure but much happier... I wasn't born an atheist...it's just something that evolved from believer to agnostic to where i am now... My dogs (present and past) represent some of the happiest creatures on the planet and none of them can read or write although it is interesting that DOG is GOD spelled backwards...:)
You’re right there. Paul really covered all the important details of list building. A lot of newbies are not taking list building very seriously, what they don’t know is that list building should really be the number 1 priority online. Thank you...
Considering all the countries you listed, Their birth rates may be higher but quality of life is much lower. So they must have more offspring for their society or however you want to categorize them to be able to survive in worse living conditions. A survival of the fittest kind of terminology. Yet countries with the highest unbelief rates have fewer birth rates but they live a longer and better quality of lives. But I would have to agree with you on the explanations of the placebo effect and the creation of an idea. There is my 2 cents. Have a nice Day.
Our pressure sensors provide accurate and reliable measurements. Our main products contains melt pressure transmitter,pressure transmitter, automotive pressure sensors, pressure gauge, temperature transducer and pressure instrumentation.
PV system - Rang from 500W to 1MW or larger.On-grid or off-grid. Easy to operate, maintenance cost minimized.
W.E. solar is a professional manufacturer of photovoltaic module (PV module),Power Inverter,Automatic Voltage Regulator,Industrial grade UPS,On-line UPS, Solar Inverter in China polycrystalline PV module 35-280W 5 years limited warranty on material and workmanship.
W.E. solar is a professional manufacturer of photovoltaic module (PV module),Power Inverter,Automatic Voltage Regulator,Industrial grade UPS,On-line UPS, Solar Inverter in China
PV grid-connected inverter
higher cost-efficiency
quick and easy installation
DIN VDE 0126,UL1741,DK5940,AS4777,G83/1
Ranging from 1KW to1MW grid-connected PV system.Easy to operate. Maintenance cost reasonable. Cost effectiveness. Designed fully in line with local environment.
5 years limited warranty on material and workmanship.
10 years and 25 years limited warranty for minimum power output.
Established in 1998, Seko Industrial Co.Ltd. is a leading manufacturer of household electrical appliances, products include: towel rail, patio heater, panel heater, convector, fan heater, Industrial fan heater, kerosene heater, halogen heater, carbon fiber heater, quartz heater, etc.
Abdominal exercise equipments such as AB Rocket, AB circle, AB coaster, AB lounge, AB flyer, Total core, Balance power;
Home fitness machines such as magnetic bike, exercise bike, spinning bike, fitness bike, indoor bike trainer, stationary bike, elliptical bike, treadmill;
Ourdoor fitness and sports equipments such as trampoline, mini folding bike, camping tent etc.
Shanghai Zhaohui Pressure Apparstus Co.,Ltd is a leader providing pressure and temperature sensors and instruments with ZHYQ brand. We have more than 10 years experience in this area.
The towel warmer is elegance European style designed with high thermal conductivity.
Our Roller Blinds collection ranged from Plain fabrics, Black out fabrics, Jacquard fabrics , Print fabrics, Embroidery Fabrics. Sunscreen Fabrics, PVC fabrics,Sunshade fabrics etc.
<a href="http://www.cnwaterfilter.com/water_purifier_system.htm" >Water purifier system</a>
HY Series rubber injection molding machine is an advanced hot-pressing molding equipment for rubber products ,with a national patent (Patent No. : ZL2004201107481.9), its structure is compact with wide applicability, high efficiency and high yield.
Perhaps this is one of the most interesting blogs that I have ever seen. Interesting article, Funny comment. Keep it up!
love converse all star,love yourself.High quality low price.It's fit for you.
HY Series rubber injection molding machine is an advanced hot-pressing molding equipment for rubber products ,with a national patent (Patent No. : ZL2004201107481.9), its structure is compact with wide applicability, high efficiency and high yield.
Our Roller Blinds collection ranged from Plain fabrics, Black out fabrics, Jacquard fabrics , Print fabrics, Embroidery Fabrics. Sunscreen Fabrics, PVC fabrics,Sunshade fabrics etc.
Interesting article, Funny comment. Keep it up! I was just wondering how to pull this off. I'm guessing some clients probably want a mobile version for their site and so I'm glad you posted this because I was clueless earlier.
Some times, to a certain need, we have to convert PDF to image for enjoyment.
Discount Wholesale Electronics, Wholesale Cell Phones, Electronic Gadgets and More from the Best Dropship Wholesaler
Discount Wholesale Electronics, Wholesale Cell Phones, Electronic Gadgets and More from the Best Dropship Wholesaler
I thought that I would knew everything that you could possibly show in this screencast... but apparently I was wrong, I learned many things. Thank you very much again! :)
Rails on mobile devices have always been a serious challenge for me. I don't know why and I don't know how. It's just a hindrance for me.
That's why I'm glad to have found this post. I learned a TON from it as well! :-)
Is this image your copyright or can I use it on my website?
Is this image your copyright or can I use it on my website?
Thanks for sharing your article. I really enjoyed it. I put a link to my site to here so other people can read it. My readers have about the same interets
Your site is amazing.I am very impressed to see this,i want to come back for visiting your site.Keep doing Good as well as you can..
As i go through your post. my queries solved automatically. i like to read more from you.
I agree with your Blog and I will be back to check it more in the future so please keep up your work. I love your content & the way that you write. It looks like you’ve been doing this for a while now, how long have you been blogging for?
Thanx for the effort, keep up the good work Great work, I am going to start a small Blog Engine course work using your site I hope you enjoy blogging with the popular BlogEngine.net.Thethoughts you express are really awesome. Hope you will right some more posts.






