!!! Listings aus dem Artikel "Auf Gleis drei" !!! von Mike Zaschka und Stefan Sprenger !!! in iX 10/2010, S. 72 !!! Listing 1: Verwendung alternativer Generatoren module AppName class Application < Rails::Application config.generators do |g| g.orm :active_record g.template_engine :erb g.test_framework :rspec end end end !!! Listing 2: Benötigte Gems im Gemfile angeben source 'http://rubygems.org' gem 'rails', '3.0.0' gem 'sqlite3-ruby', :require => 'sqlite3' gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3' !!! Listing 3: Model mit Validierung und Named Scope class User < ActiveRecord::Base validates :username, :presence => true, :maximum => 50 scope :active, where(:active => true) end !!! Listing 4: Verfügbare Formate über Controller-APIs class UsersController < ApplicationController respond_to :html, :xml, :json def index respond_with(@users = User.find(:all)) end end !!! Listing 5: Definition der Routes in der Konfigurationsdatei MyApp::Application.routes do resources :user mount MySinatraBlogApp, :at => "/blog" end !!! Listing 6: Ajax-Link in Rails 3 # Rails Helper <%= link_to "delete", user_path(@user), :method => :delete, :confirm => "Are you sure?" %> # Generierter HTML-Code delete