BACKTRACE

(condense)

Back to Posts List

GET

iphone on rails

OUT-OF-DATE, a lot of better ways to do this now

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</span><span>&nbsp;=&nbsp;Movie.top_movies&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="variable">movie = @top_movies.first  
  21.       
  22.     respond_to do |format|  
  23.       format.html # index.html.erb  
  24.       format.iphone_html #index.iphone_html.erb  
  25.     end  
  26.   end  
  27. end  

POST

blog comments powered by Disqus

I Don't have cookies.

ELAD ENV

Variable Value
LINKEDIN
TWITTER
FACEBOOK
GITHUB
WWR
IRC
{ 'irc.freenode.net' => [ '#rubyonrails', '#railsbridge', '#ruby', '#mootools' ]}
SKYPE
eladmeidar

You're seeing this error because I think it is funny.