Hi, this blog is no longer maintained, my new blog is here

Ruby On Rails and a Conning Israeli entrepreneur

iphone on rails

A simple way to build iPhone specific interface with Rails

  1. class ApplicationController < ActionController::Base  
  2.   exempt_from_layout('iphone_html.erb')  
  3.     
  4.   before_filter :check_iphone  
  5.     
  6.   protected  
  7.   def iphone?  
  8.     request.user_agent.include?('iPhone')  
  9.   end  
  10.     
  11.   def check_iphone  
  12.     if iphone?  
  13.       request.parameters[:format] = 'iphone_html'  
  14.     end  
  15.   end  
  16. end  
  17.   
  18. class DashboardController < ApplicationController  
  19.   def index  
  20.     @top_movies = Movie.top_movies  
  21.     @movie = @top_movies.first  
  22.       
  23.     respond_to do |format|  
  24.       format.html # index.html.erb  
  25.       format.iphone_html #index.iphone_html.erb  
  26.     end  
  27.   end  
  28. end  

4 comments:

  Alexey

September 23, 2007 at 11:19 AM

huh nice,
only what we need is to have iphone in israel :)

400$ on ebay, unlocked for any gsm

  nreilly

November 25, 2007 at 9:30 PM

What you really want to check for here is mobile safari, not the iPhone as such. Mobile safari is used on both the iPhone and the iPod touch.

Details are here.

  Anonymous

June 5, 2008 at 1:15 AM

We all know Apple iPhone is very rich in multimedia features including Internet capabilities... and of course the price isn't affordable to the average people...

So if you own this Gadget I think it's better to have an extra care specially the screen, it needs Incase iPhone Slider Case to protect your iPhone from unwanted scratch.

This is only an advice... don't think it seriously if you don't want.

Peace!

  Elad Meidar

June 5, 2008 at 5:56 AM

That's right.
i don't really think it's too expensive, but still, it is one of the best things i purchased.


The Web Ask eizesus.com

Subscribe

    follow me on Twitter

    Twiters Around

    About Me

    My photo
    I am a web developer for more than 9 years, managed, cried, coded, designed and made money in this industry. now trying to do it again.

    Labels