Rails上的iPhone

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Rails上的iPhone相关的知识,希望对你有一定的参考价值。

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

以上是关于Rails上的iPhone的主要内容,如果未能解决你的问题,请参考以下文章