The Depot Application

The Depot Application

21.2 Routing Requests 20 ActiveRecord: Object Life Cycle

21 Action Controller: Routing and URLs

ruby -rubygems /home/rubys/git/rails/bin/rails new restful
      create  
      create  README
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/controllers/application_controller.rb
      create  app/mailers
      create  app/models
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/test.rb
      create  config/environments/production.rb
      create  config/initializers
      create  config/initializers/mime_types.rb
      create  config/initializers/inflections.rb
      create  config/initializers/session_store.rb
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/secret_token.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  log
      create  log/server.log
      create  log/production.log
      create  log/development.log
      create  log/test.log
      create  public
      create  public/500.html
      create  public/robots.txt
      create  public/favicon.ico
      create  public/422.html
      create  public/404.html
      create  public/index.html
      create  public/images
      create  public/images/rails.png
      create  public/stylesheets
      create  public/stylesheets/.gitkeep
      create  public/javascripts
      create  public/javascripts/prototype.js
      create  public/javascripts/dragdrop.js
      create  public/javascripts/rails.js
      create  public/javascripts/effects.js
      create  public/javascripts/controls.js
      create  public/javascripts/application.js
      create  script
      create  script/rails
      create  test
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  test/fixtures
      create  test/unit
      create  test/functional
      create  test/integration
      create  tmp
      create  tmp/sessions
      create  tmp/sockets
      create  tmp/cache
      create  tmp/pids
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
bundle install
Using rake (0.8.7) 
Using abstract (1.0.0) 
Using activesupport (3.0.0.rc) from source at /home/rubys/git/rails 
Using builder (2.1.2) 
Using i18n (0.4.1) 
Using activemodel (3.0.0.rc) from source at /home/rubys/git/rails 
Using erubis (2.6.6) 
Using rack (1.2.1) 
Using rack-mount (0.6.9) 
Using rack-test (0.5.4) 
Using tzinfo (0.3.22) 
Using actionpack (3.0.0.rc) from source at /home/rubys/git/rails 
Using mime-types (1.16) 
Using polyglot (0.3.1) 
Using treetop (1.4.8) 
Using mail (2.2.5) 
Using actionmailer (3.0.0.rc) from source at /home/rubys/git/rails 
Using arel (0.4.0) 
Using activerecord (3.0.0.rc) from source at /home/rubys/git/rails 
Using activeresource (3.0.0.rc) from source at /home/rubys/git/rails 
Using bundler (1.0.0.rc.3) 
Using thor (0.14.0) 
Using railties (3.0.0.rc) from source at /home/rubys/git/rails 
Using rails (3.0.0.rc) from source at /home/rubys/git/rails 
Using sqlite3-ruby (1.3.1) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
*[32m
Your bundle was installed to `/home/rubys/.rvm/gems/ruby-1.8.8-r28862`*[0m
edit config/routes.rb
Restful::Application.routes.draw do
  # ...
 
  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
   match ':controller(/:action(/:id(.:format)))'
end
rails generate scaffold article title:string summary:text content:text
      invoke  active_record
      create    db/migrate/20100807132052_create_articles.rb
      create    app/models/article.rb
      invoke    test_unit
      create      test/unit/article_test.rb
      create      test/fixtures/articles.yml
       route  resources :articles
      invoke  scaffold_controller
      create    app/controllers/articles_controller.rb
      invoke    erb
      create      app/views/articles
      create      app/views/articles/index.html.erb
      create      app/views/articles/edit.html.erb
      create      app/views/articles/show.html.erb
      create      app/views/articles/new.html.erb
      create      app/views/articles/_form.html.erb
      invoke    test_unit
      create      test/functional/articles_controller_test.rb
      invoke    helper
      create      app/helpers/articles_helper.rb
      invoke      test_unit
      create        test/unit/helpers/articles_helper_test.rb
      invoke  stylesheets
      create    public/stylesheets/scaffold.css
rake db:migrate
mv 20100807132052_create_articles.rb 20100301000001_create_articles.rb
(in /home/rubys/git/awdwr/work-188/restful)
==  CreateArticles: migrating =================================================
-- create_table(:articles)
   -> 0.0019s
==  CreateArticles: migrated (0.0021s) ========================================
 
rake routes
(in /home/rubys/git/awdwr/work-188/restful)
             GET    /articles(.:format)                    {:action=>"index", :controller=>"articles"}
    articles POST   /articles(.:format)                    {:action=>"create", :controller=>"articles"}
 new_article GET    /articles/new(.:format)                {:action=>"new", :controller=>"articles"}
             GET    /articles/:id(.:format)                {:action=>"show", :controller=>"articles"}
             PUT    /articles/:id(.:format)                {:action=>"update", :controller=>"articles"}
     article DELETE /articles/:id(.:format)                {:action=>"destroy", :controller=>"articles"}
edit_article GET    /articles/:id/edit(.:format)           {:action=>"edit", :controller=>"articles"}
                    /:controller(/:action(/:id(.:format))) 
edit config/routes.rb
Restful::Application.routes.draw do
  resources :articles
 
  # ...
 
   match ':controller(/:action(/:id(.:format)))'
end
edit app/controllers/articles_controller.rb
class ArticlesController < ApplicationController
  # GET /articles
  # GET /articles.xml
  def index
    @articles = Article.all
 
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @articles }
    end
  end
 
  # GET /articles/1
  # GET /articles/1.xml
  def show
    @article = Article.find(params[:id])
 
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @article }
    end
  end
 
  # GET /articles/new
  # GET /articles/new.xml
  def new
    @article = Article.new
 
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @article }
    end
  end
 
  # GET /articles/1/edit
  def edit
    @article = Article.find(params[:id])
  end
 
  # POST /articles
  # POST /articles.xml
  def create
    @article = Article.new(params[:article])
 
    respond_to do |format|
      if @article.save
        format.html { redirect_to(@article, :notice => 'Article was successfully created.') }
        format.xml  { render :xml => @article, :status => :created,
                             :location => @article }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @article.errors,
                             :status => :unprocessable_entity }
      end
    end
  end
 
  # PUT /articles/1
  # PUT /articles/1.xml
  def update
    @article = Article.find(params[:id])
 
    respond_to do |format|
      if @article.update_attributes(params[:article])
        format.html { redirect_to(@article, :notice => 'Article was successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @article.errors,
                             :status => :unprocessable_entity }
      end
    end
  end
 
  # DELETE /articles/1
  # DELETE /articles/1.xml
  def destroy
    @article = Article.find(params[:id])
    @article.destroy
 
    respond_to do |format|
      format.html { redirect_to(articles_url) }
      format.xml  { head :ok }
    end
  end
end
edit app/views/articles/index.html.erb
<h1>Listing articles</h1>
 
<table>
  <tr>
    <th>Title</th>
    <th>Summary</th>
    <th>Content</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>
 
<% @articles.each do |article| %>
  <tr>
    <td><%= article.title %></td>
    <td><%= article.summary %></td>
    <td><%= article.content %></td>
    <td><%= link_to 'Show', article %></td>
    <td><%= link_to 'Edit', edit_article_path(article) %></td>
    <td><%= link_to 'Destroy', article, :confirm => 'Are you sure?',
                                        :method => :delete %></td>
  </tr>
<% end %>
</table>
 
<br />
 
<%= link_to 'New Article', new_article_path %>
edit config/routes.rb
Restful::Application.routes.draw do
  resources :articles do
    collection do
      get :recent
    end
  end
 
  # ...
 
 
  # ...
  # The priority is based upon order of creation:
  # first created -> highest priority.
 
  # Sample of regular route:
  #   match 'products/:id' => 'catalog#view'
  # Keep in mind you can assign values other than :controller and :action
 
  # Sample of named route:
  #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
  # This route can be invoked with purchase_url(:id => product.id)
 
  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products
 
  # Sample resource route with options:
  #   resources :products do
  #     member do
  #       get :short
  #       post :toggle
  #     end
  #
  #     collection do
  #       get :sold
  #     end
  #   end
 
  # Sample resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end
 
  # Sample resource route with more complex sub-resources
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get :recent, :on => :collection
  #     end
  #   end
 
  # Sample resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end
 
  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  # root :to => "welcome#index"
 
  # See how all your routes lay out with "rake routes"
 
  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
   match ':controller(/:action(/:id(.:format)))'
end
rake routes
(in /home/rubys/git/awdwr/work-188/restful)
recent_articles GET    /articles/recent(.:format)             {:action=>"recent", :controller=>"articles"}
                GET    /articles(.:format)                    {:action=>"index", :controller=>"articles"}
       articles POST   /articles(.:format)                    {:action=>"create", :controller=>"articles"}
    new_article GET    /articles/new(.:format)                {:action=>"new", :controller=>"articles"}
                GET    /articles/:id(.:format)                {:action=>"show", :controller=>"articles"}
                PUT    /articles/:id(.:format)                {:action=>"update", :controller=>"articles"}
        article DELETE /articles/:id(.:format)                {:action=>"destroy", :controller=>"articles"}
   edit_article GET    /articles/:id/edit(.:format)           {:action=>"edit", :controller=>"articles"}
                       /:controller(/:action(/:id(.:format))) 
edit config/routes.rb
Restful::Application.routes.draw do
  resources :articles do
    member do
      post :embargo, :release
    end
  end
 
  # ...
 
 
  # ...
  # The priority is based upon order of creation:
  # first created -> highest priority.
 
  # Sample of regular route:
  #   match 'products/:id' => 'catalog#view'
  # Keep in mind you can assign values other than :controller and :action
 
  # Sample of named route:
  #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
  # This route can be invoked with purchase_url(:id => product.id)
 
  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products
 
  # Sample resource route with options:
  #   resources :products do
  #     member do
  #       get :short
  #       post :toggle
  #     end
  #
  #     collection do
  #       get :sold
  #     end
  #   end
 
  # Sample resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end
 
  # Sample resource route with more complex sub-resources
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get :recent, :on => :collection
  #     end
  #   end
 
  # Sample resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end
 
  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  # root :to => "welcome#index"
 
  # See how all your routes lay out with "rake routes"
 
  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
   match ':controller(/:action(/:id(.:format)))'
end
rake routes
(in /home/rubys/git/awdwr/work-188/restful)
embargo_article POST   /articles/:id/embargo(.:format)        {:action=>"embargo", :controller=>"articles"}
release_article POST   /articles/:id/release(.:format)        {:action=>"release", :controller=>"articles"}
                GET    /articles(.:format)                    {:action=>"index", :controller=>"articles"}
       articles POST   /articles(.:format)                    {:action=>"create", :controller=>"articles"}
    new_article GET    /articles/new(.:format)                {:action=>"new", :controller=>"articles"}
                GET    /articles/:id(.:format)                {:action=>"show", :controller=>"articles"}
                PUT    /articles/:id(.:format)                {:action=>"update", :controller=>"articles"}
        article DELETE /articles/:id(.:format)                {:action=>"destroy", :controller=>"articles"}
   edit_article GET    /articles/:id/edit(.:format)           {:action=>"edit", :controller=>"articles"}
                       /:controller(/:action(/:id(.:format))) 
edit config/routes.rb
Restful::Application.routes.draw do
  resources :articles do
    collection do
      namespace('new') { post :shortform }
    end
  end
 
  # ...
 
 
  # ...
  # The priority is based upon order of creation:
  # first created -> highest priority.
 
  # Sample of regular route:
  #   match 'products/:id' => 'catalog#view'
  # Keep in mind you can assign values other than :controller and :action
 
  # Sample of named route:
  #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
  # This route can be invoked with purchase_url(:id => product.id)
 
  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products
 
  # Sample resource route with options:
  #   resources :products do
  #     member do
  #       get :short
  #       post :toggle
  #     end
  #
  #     collection do
  #       get :sold
  #     end
  #   end
 
  # Sample resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end
 
  # Sample resource route with more complex sub-resources
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get :recent, :on => :collection
  #     end
  #   end
 
  # Sample resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end
 
  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  # root :to => "welcome#index"
 
  # See how all your routes lay out with "rake routes"
 
  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
   match ':controller(/:action(/:id(.:format)))'
end
rake routes
(in /home/rubys/git/awdwr/work-188/restful)
shortform_new_articles POST   /articles/new/shortform(.:format)      {:action=>"shortform", :controller=>"new/articles"}
                       GET    /articles(.:format)                    {:action=>"index", :controller=>"articles"}
              articles POST   /articles(.:format)                    {:action=>"create", :controller=>"articles"}
           new_article GET    /articles/new(.:format)                {:action=>"new", :controller=>"articles"}
                       GET    /articles/:id(.:format)                {:action=>"show", :controller=>"articles"}
                       PUT    /articles/:id(.:format)                {:action=>"update", :controller=>"articles"}
               article DELETE /articles/:id(.:format)                {:action=>"destroy", :controller=>"articles"}
          edit_article GET    /articles/:id/edit(.:format)           {:action=>"edit", :controller=>"articles"}
                              /:controller(/:action(/:id(.:format))) 
edit config/routes.rb
Restful::Application.routes.draw do
  resources :articles do
    resources :comments
  end
 
  # ...
 
   match ':controller(/:action(/:id(.:format)))'
end
rake routes
(in /home/rubys/git/awdwr/work-188/restful)
                     GET    /articles/:article_id/comments(.:format)          {:action=>"index", :controller=>"comments"}
    article_comments POST   /articles/:article_id/comments(.:format)          {:action=>"create", :controller=>"comments"}
 new_article_comment GET    /articles/:article_id/comments/new(.:format)      {:action=>"new", :controller=>"comments"}
                     GET    /articles/:article_id/comments/:id(.:format)      {:action=>"show", :controller=>"comments"}
                     PUT    /articles/:article_id/comments/:id(.:format)      {:action=>"update", :controller=>"comments"}
     article_comment DELETE /articles/:article_id/comments/:id(.:format)      {:action=>"destroy", :controller=>"comments"}
edit_article_comment GET    /articles/:article_id/comments/:id/edit(.:format) {:action=>"edit", :controller=>"comments"}
                     GET    /articles(.:format)                               {:action=>"index", :controller=>"articles"}
            articles POST   /articles(.:format)                               {:action=>"create", :controller=>"articles"}
         new_article GET    /articles/new(.:format)                           {:action=>"new", :controller=>"articles"}
                     GET    /articles/:id(.:format)                           {:action=>"show", :controller=>"articles"}
                     PUT    /articles/:id(.:format)                           {:action=>"update", :controller=>"articles"}
             article DELETE /articles/:id(.:format)                           {:action=>"destroy", :controller=>"articles"}
        edit_article GET    /articles/:id/edit(.:format)                      {:action=>"edit", :controller=>"articles"}
                            /:controller(/:action(/:id(.:format)))            
rails generate model comment comment:text article_id:integer
      invoke  active_record
      create    db/migrate/20100807132109_create_comments.rb
      create    app/models/comment.rb
      invoke    test_unit
      create      test/unit/comment_test.rb
      create      test/fixtures/comments.yml
rails generate controller comments new edit update destroy
      create  app/controllers/comments_controller.rb
       route  get "comments/destroy"
       route  get "comments/update"
       route  get "comments/edit"
       route  get "comments/new"
      invoke  erb
      create    app/views/comments
      create    app/views/comments/new.html.erb
      create    app/views/comments/edit.html.erb
      create    app/views/comments/update.html.erb
      create    app/views/comments/destroy.html.erb
      invoke  test_unit
      create    test/functional/comments_controller_test.rb
      invoke  helper
      create    app/helpers/comments_helper.rb
      invoke    test_unit
      create      test/unit/helpers/comments_helper_test.rb
rm app/views/comments/destroy.html.erb
rm app/views/comments/update.html.erb
edit app/models/article.rb
class Article < ActiveRecord::Base
  has_many :comments
end
edit app/models/comment.rb
class Comment < ActiveRecord::Base
  belongs_to :article
end
rake db:migrate
mv 20100807132109_create_comments.rb 20100301000002_create_comments.rb
(in /home/rubys/git/awdwr/work-188/restful)
==  CreateComments: migrating =================================================
-- create_table(:comments)
   -> 0.0018s
==  CreateComments: migrated (0.0019s) ========================================
 
edit app/views/articles/show.html.erb
<p id="notice"><%= notice %></p>
 
<p>
  <b>Title:</b>
  <%= @article.title %>
</p>
 
<p>
  <b>Summary:</b>
  <%= @article.summary %>
</p>
 
<p>
  <b>Content:</b>
  <%= @article.content %>
</p>
 
 
<% unless @article.comments.empty? %>
  <%= render :partial => "/comments/comment",
	           :collection => @article.comments %>
<% end %>
 
<%= link_to "Add comment", new_article_comment_url(@article) %> |
<%= link_to 'Edit', edit_article_path(@article) %> |
<%= link_to 'Back', articles_path %>
edit app/views/comments/_comment.html.erb
<div class="comment">
  <p>
    <strong>Comment last updated: <%= comment.updated_at %></strong>
    <%= link_to "Edit", edit_article_comment_url(:id => comment,
                                      :article_id => comment.article) %>
 
    <%= link_to "Delete", article_comment_url(:id => comment,
                                      :article_id => comment.article), 
                                      :method => :delete %>
  </p>
  <blockquote>
    <%=h comment.comment %>
  </blockquote>
 
 
</div>                                    
edit app/views/comments/_form.html.erb
<%= form.text_area  :comment, :rows => 3 %>
edit app/views/comments/edit.html.erb
<h1>Editing comment</h1>
 
<%= error_messages_for :comment %>
 
<% form_for([@article,@comment]) do |f| %>
  <p>
    <b>Comment</b><br />
    <%= f.text_area :comment %>
  </p>
 
  <p>
    <b>Article</b><br />
    <%= f.text_field :article_id %>
  </p>
 
  <p>
    <%= f.submit "Update" %>
  </p>
<% end %>
 
<%= link_to 'Back', article_path(@article) %>
edit app/views/comments/new.html.erb
<% form_for [@article, @comment] do |form| %>
<fieldset>
  <legend>Add a Comment</legend>
	
  <%= render :partial => 'form', :object => form %>
 
  <p>
    <%= submit_tag "Create" %>
  </p>
</fieldset>
<% end %>
edit app/controllers/comments_controller.rb
class CommentsController < ApplicationController
 
  before_filter :find_article
 
  def new
    @comment = Comment.new
  end
 
  def edit
    @comment = @article.comments.find(params[:id])
  end
 
  def create
    @comment = Comment.new(params[:comment])
    if (@article.comments << @comment)
      redirect_to article_url(@article)
    else
      render :action => :new
    end
  end
 
  def update
    @comment = @article.comments.find(params[:id])
    if @comment.update_attributes(params[:comment])
      redirect_to article_url(@article)
    else
      render :action => :edit
    end
  end
 
  def destroy
    comment = @article.comments.find(params[:id])
    @article.comments.delete(comment)
    redirect_to article_url(@article)
  end
 
private
 
  def find_article
    @article_id = params[:article_id]
    return(redirect_to(articles_url)) unless @article_id
    @article = Article.find(@article_id)
  end
 
end
ruby -rubygems /home/rubys/git/rails/bin/rails new routing
      create  
      create  README
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/controllers/application_controller.rb
      create  app/mailers
      create  app/models
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/test.rb
      create  config/environments/production.rb
      create  config/initializers
      create  config/initializers/mime_types.rb
      create  config/initializers/inflections.rb
      create  config/initializers/session_store.rb
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/secret_token.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  log
      create  log/server.log
      create  log/production.log
      create  log/development.log
      create  log/test.log
      create  public
      create  public/500.html
      create  public/robots.txt
      create  public/favicon.ico
      create  public/422.html
      create  public/404.html
      create  public/index.html
      create  public/images
      create  public/images/rails.png
      create  public/stylesheets
      create  public/stylesheets/.gitkeep
      create  public/javascripts
      create  public/javascripts/prototype.js
      create  public/javascripts/dragdrop.js
      create  public/javascripts/rails.js
      create  public/javascripts/effects.js
      create  public/javascripts/controls.js
      create  public/javascripts/application.js
      create  script
      create  script/rails
      create  test
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  test/fixtures
      create  test/unit
      create  test/functional
      create  test/integration
      create  tmp
      create  tmp/sessions
      create  tmp/sockets
      create  tmp/cache
      create  tmp/pids
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
bundle install
Using rake (0.8.7) 
Using abstract (1.0.0) 
Using activesupport (3.0.0.rc) from source at /home/rubys/git/rails 
Using builder (2.1.2) 
Using i18n (0.4.1) 
Using activemodel (3.0.0.rc) from source at /home/rubys/git/rails 
Using erubis (2.6.6) 
Using rack (1.2.1) 
Using rack-mount (0.6.9) 
Using rack-test (0.5.4) 
Using tzinfo (0.3.22) 
Using actionpack (3.0.0.rc) from source at /home/rubys/git/rails 
Using mime-types (1.16) 
Using polyglot (0.3.1) 
Using treetop (1.4.8) 
Using mail (2.2.5) 
Using actionmailer (3.0.0.rc) from source at /home/rubys/git/rails 
Using arel (0.4.0) 
Using activerecord (3.0.0.rc) from source at /home/rubys/git/rails 
Using activeresource (3.0.0.rc) from source at /home/rubys/git/rails 
Using bundler (1.0.0.rc.3) 
Using thor (0.14.0) 
Using railties (3.0.0.rc) from source at /home/rubys/git/rails 
Using rails (3.0.0.rc) from source at /home/rubys/git/rails 
Using sqlite3-ruby (1.3.1) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
*[32m
Your bundle was installed to `/home/rubys/.rvm/gems/ruby-1.8.8-r28862`*[0m
edit config/routes.rb
Routing::Application.routes.draw do
  # ...
 
  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
   match ':controller(/:action(/:id(.:format)))'
end
rails generate controller store index add_to_cart
      create  app/controllers/store_controller.rb
       route  get "store/add_to_cart"
       route  get "store/index"
      invoke  erb
      create    app/views/store
      create    app/views/store/index.html.erb
      create    app/views/store/add_to_cart.html.erb
      invoke  test_unit
      create    test/functional/store_controller_test.rb
      invoke  helper
      create    app/helpers/store_helper.rb
      invoke    test_unit
      create      test/unit/helpers/store_helper_test.rb
cp -v /home/rubys/git/awdwr/data/routing/* config
`/home/rubys/git/awdwr/data/routing/routes.rb' -> `config/routes.rb'
`/home/rubys/git/awdwr/data/routing/routes_with_conditions.rb' -> `config/routes_with_conditions.rb'
`/home/rubys/git/awdwr/data/routing/routes_with_names.rb' -> `config/routes_with_names.rb'
`/home/rubys/git/awdwr/data/routing/routing_conditions_test.rb' -> `config/routing_conditions_test.rb'
`/home/rubys/git/awdwr/data/routing/routing_test.rb' -> `config/routing_test.rb'
mv -v config/*_test.rb test/unit
`config/routing_conditions_test.rb' -> `test/unit/routing_conditions_test.rb'
`config/routing_test.rb' -> `test/unit/routing_test.rb'
rake db:schema:dump
(in /home/rubys/git/awdwr/work-188/routing)
rake test
(in /home/rubys/git/awdwr/work-188/routing)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes_with_conditions.rb:1)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes.rb:3)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes.rb:3)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.8-r28862/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes_with_conditions.rb:1)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes.rb:3)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes_with_conditions.rb:1)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes.rb:3)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes_with_conditions.rb:1)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes_with_conditions.rb:1)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes.rb:3)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes_with_conditions.rb:1)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes.rb:3)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
.....
Finished in 0.250993 seconds.
 
5 tests, 29 assertions, 0 failures, 0 errors
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes_with_conditions.rb:1)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/work-188/routing/config/routes.rb:3)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from initialize at /home/rubys/git/rails/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb:33)
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.8-r28862/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
..
Finished in 0.199412 seconds.
 
2 tests, 2 assertions, 0 failures, 0 errors

21.2 Routing Requests 20 ActiveRecord: Object Life Cycle