Screencast: Rails für mobile Geräte
Der mobile Markt wächst stetig weiter und hat andere Anforderungen an Webapplikationen auf dem mobilen Gerät als für Desktop-Geräte. Ryan zeigt in seinem Screencast wie Rails angepasst werden kann um mobile Geräte zu unterstützen. Dabei kommt mitunter jQTouch zum Einsatz.
Download:
Download (55.4 MB, 13:26)
alternative download for iPod & Apple TV (22.4 MB, 13:26)
Resourcen:
Quellcode:
# config/initializers/mime_types.rb
Mime::Type.register_alias "text/html", :mobile
# application_controller.rb
before_filter :prepare_for_mobile
private
def mobile_device?
if session[:mobile_param]
session[:mobile_param] == "1"
else
request.user_agent =~ /Mobile|webOS/
end
end
helper_method :mobile_device?
def prepare_for_mobile
session[:mobile_param] = params[:mobile] if params[:mobile]
request.format = :mobile if mobile_device?
end
<!-- views/layouts/application.html.erb -->
<%= stylesheet_link_tag 'mobile' if mobile_device? %>
...
<p>
<% if mobile_device? %>
<%= link_to "Full Site", :mobile => 0 %>
<% else %>
<%= link_to "Mobile Site", :mobile => 1 %>
<% end %>
</p>
<!-- views/layouts/application.mobile.erb -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title><%= h(yield(:title) || "Untitled") %></title>
<%= stylesheet_link_tag "/jqtouch/jqtouch.min.css", "/jqtouch/themes/apple/theme.min.css" %>
<%= javascript_include_tag "/jqtouch/jquery.1.3.2.min.js", "/jqtouch/jqtouch.min.js", "mobile" %>
<%= yield(:head) %>
</head>
<body>
<div class="current">
<%- if show_title? -%>
<div class="toolbar">
<%= link_to "Back", nil, :class => "back" unless current_page? root_path %>
<h1><%=h yield(:title) %></h1>
<%= link_to "Full Site", root_url(:mobile => 0), :class => "button", :rel => "external" %>
<%= yield(:toolbar) %>
</div>
<%- end -%>
<% unless flash.empty? %>
<div class="info">
<%- flash.each do |name, msg| -%>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
<%- end -%>
</div>
<% end %>
<%= yield %>
</div>
</body>
</html>
<!-- views/projects/index.mobile.erb -->
<% title "Projects" %>
<ul>
<% for project in @projects %>
<li class="arrow">
<%= link_to h(project.name), project %>
<small class="counter"><%= project.tasks.size %></small>
</li>
<% end %>
</ul>
<ul><li class="arrow"><%= link_to "New Project", new_project_path %></li></ul>
Eingestellt am 01.02.2010 um 15:34
Kategorie: Tutorials
Suchen auf rubyonrails.de
Tags
2.0 Action Active-Record ActiveRecord Ajax Buch Capistrano Enterprise Event Formulare Gewinnspiel Grundlagen IDE irb jQuery Kochbuch Konferenz Mac OpenRoRBook OReilly OSX Passenger Phusion Plugin PragProgs Rails Rails 3 RailsWayCon Release Release Candidate Routing Ruby Ruby 1.9 RubyGems rubyonrails.de Ryan Bates Scaffolding Screencast Script-Tip Security Tutorial Upgrade Video Views WindowsAktuelle Artikel
- Alle Links zu Rails 3
- Rails 3 Upgrade Handbook PDF
- Ruby on Rails 3: Moderne Webentwicklung mit Ruby
- Rails 3.0 ist fertig
- Screencast: Polling nach Aktualisierungen
- Screencast: Sortierbare Tabellen
- Subversion und .svn Verzeichnisse finden und löschen
- Screencast: Upgrade auf Rails 3 Teil 3
- Screencast: Upgrade auf Rails 3 Teil 2
- Screencast: Upgrade auf Rails 3 Teil 1
Artikel Archiv
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- May 2009
- April 2009
- March 2009
- February 2009
- December 2008
- November 2008
- August 2008
- July 2008
- June 2008
- May 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
Aktuelle Rails Version + Abhängigkeiten:
Gem rails-3.0.0actionmailer (= 3.0.0, runtime)
actionpack (= 3.0.0, runtime)
activerecord (= 3.0.0, runtime)
activeresource (= 3.0.0, runtime)
activesupport (= 3.0.0, runtime)
bundler (~> 1.0.0, runtime)
railties (= 3.0.0, runtime)
Rails auf Rubyforge
Rails auf Github