The Depot Application

The Depot Application

21.2 Routing Requests 20 ActiveRecord: Object Life Cycle

21 Action Controller: Routing and URLs

bundle exec /home/rubys/git/rails/bin/rails new restful --skip-bundle --dev
      create  
      create  README
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/mailers
      create  app/models
      create  app/views/layouts/application.html.erb
      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/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.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/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  public/images
      create  public/images/rails.png
      create  public/stylesheets
      create  public/stylesheets/.gitkeep
      create  public/javascripts
      create  public/javascripts/application.js
      create  public/javascripts/controls.js
      create  public/javascripts/dragdrop.js
      create  public/javascripts/effects.js
      create  public/javascripts/prototype.js
      create  public/javascripts/rails.js
      create  script
      create  script/rails
      create  test
      create  test/fixtures
      create  test/functional
      create  test/integration
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  test/unit
      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.9.2.2) 
Using abstract (1.0.0) 
Using activesupport (3.0.15) 
Using builder (2.1.2) 
Using i18n (0.5.0) 
Using activemodel (3.0.15) 
Using erubis (2.6.6) 
Using rack (1.2.5) 
Using rack-mount (0.6.14) 
Using rack-test (0.5.7) 
Using tzinfo (0.3.33) 
Using actionpack (3.0.15) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.2.19) 
Using actionmailer (3.0.15) 
Using braintree (2.16.0) 
Using activemerchant (1.10.0) 
Using arel (2.0.10) 
Using activerecord (3.0.15) 
Using activeresource (3.0.15) 
Using bundler (1.1.3) 
Using highline (1.6.13) 
Using net-ssh (2.5.2) 
Using net-scp (1.0.4) 
Using net-sftp (2.0.5) 
Using net-ssh-gateway (1.1.0) 
Using capistrano (2.12.0) 
Using haml (3.1.6) 
Using htmlentities (4.3.1) 
Using json (1.7.3) 
Using rdoc (3.12) 
Using thor (0.14.6) 
Using railties (3.0.15) 
Using rails (3.0.15) 
Using jquery-rails (0.2.7) 
Using minitest (3.2.0) 
Using mysql (2.8.1) 
Using sqlite3 (1.3.6) 
Using test-unit (2.5.0) 
Using will_paginate (3.0.3) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
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/20120629192135_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 20120629192135_create_articles.rb 20110711000001_create_articles.rb
==  CreateArticles: migrating =================================================
-- create_table(:articles)
   -> 0.0032s
==  CreateArticles: migrated (0.0034s) ========================================
 
rake routes
    articles GET    /articles(.:format)                    {:action=>"index", :controller=>"articles"}
             POST   /articles(.:format)                    {:action=>"create", :controller=>"articles"}
 new_article GET    /articles/new(.:format)                {:action=>"new", :controller=>"articles"}
edit_article GET    /articles/:id/edit(.:format)           {:action=>"edit", :controller=>"articles"}
     article GET    /articles/:id(.:format)                {:action=>"show", :controller=>"articles"}
             PUT    /articles/:id(.:format)                {:action=>"update", :controller=>"articles"}
             DELETE /articles/:id(.:format)                {:action=>"destroy", :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
recent_articles GET    /articles/recent(.:format)             {:action=>"recent", :controller=>"articles"}
       articles GET    /articles(.:format)                    {:action=>"index", :controller=>"articles"}
                POST   /articles(.:format)                    {:action=>"create", :controller=>"articles"}
    new_article GET    /articles/new(.:format)                {:action=>"new", :controller=>"articles"}
   edit_article GET    /articles/:id/edit(.:format)           {:action=>"edit", :controller=>"articles"}
        article GET    /articles/:id(.:format)                {:action=>"show", :controller=>"articles"}
                PUT    /articles/:id(.:format)                {:action=>"update", :controller=>"articles"}
                DELETE /articles/:id(.:format)                {:action=>"destroy", :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
embargo_article POST   /articles/:id/embargo(.:format)        {:action=>"embargo", :controller=>"articles"}
release_article POST   /articles/:id/release(.:format)        {:action=>"release", :controller=>"articles"}
       articles GET    /articles(.:format)                    {:action=>"index", :controller=>"articles"}
                POST   /articles(.:format)                    {:action=>"create", :controller=>"articles"}
    new_article GET    /articles/new(.:format)                {:action=>"new", :controller=>"articles"}
   edit_article GET    /articles/:id/edit(.:format)           {:action=>"edit", :controller=>"articles"}
        article GET    /articles/:id(.:format)                {:action=>"show", :controller=>"articles"}
                PUT    /articles/:id(.:format)                {:action=>"update", :controller=>"articles"}
                DELETE /articles/:id(.:format)                {:action=>"destroy", :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
shortform_new_articles POST   /articles/new/shortform(.:format)      {:action=>"shortform", :controller=>"new/articles"}
              articles GET    /articles(.:format)                    {:action=>"index", :controller=>"articles"}
                       POST   /articles(.:format)                    {:action=>"create", :controller=>"articles"}
           new_article GET    /articles/new(.:format)                {:action=>"new", :controller=>"articles"}
          edit_article GET    /articles/:id/edit(.:format)           {:action=>"edit", :controller=>"articles"}
               article GET    /articles/:id(.:format)                {:action=>"show", :controller=>"articles"}
                       PUT    /articles/:id(.:format)                {:action=>"update", :controller=>"articles"}
                       DELETE /articles/:id(.:format)                {:action=>"destroy", :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
    article_comments GET    /articles/:article_id/comments(.:format)          {:action=>"index", :controller=>"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"}
edit_article_comment GET    /articles/:article_id/comments/:id/edit(.:format) {:action=>"edit", :controller=>"comments"}
     article_comment GET    /articles/:article_id/comments/:id(.:format)      {:action=>"show", :controller=>"comments"}
                     PUT    /articles/:article_id/comments/:id(.:format)      {:action=>"update", :controller=>"comments"}
                     DELETE /articles/:article_id/comments/:id(.:format)      {:action=>"destroy", :controller=>"comments"}
            articles GET    /articles(.:format)                               {:action=>"index", :controller=>"articles"}
                     POST   /articles(.:format)                               {:action=>"create", :controller=>"articles"}
         new_article GET    /articles/new(.:format)                           {:action=>"new", :controller=>"articles"}
        edit_article GET    /articles/:id/edit(.:format)                      {:action=>"edit", :controller=>"articles"}
             article GET    /articles/:id(.:format)                           {:action=>"show", :controller=>"articles"}
                     PUT    /articles/:id(.:format)                           {:action=>"update", :controller=>"articles"}
                     DELETE /articles/:id(.:format)                           {:action=>"destroy", :controller=>"articles"}
                            /:controller(/:action(/:id(.:format)))            
rails generate model comment comment:text article_id:integer
      invoke  active_record
      create    db/migrate/20120629192202_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 20120629192202_create_comments.rb 20110711000002_create_comments.rb
==  CreateComments: migrating =================================================
-- create_table(:comments)
   -> 0.0016s
==  CreateComments: migrated (0.0017s) ========================================
 
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
bundle exec /home/rubys/git/rails/bin/rails new routing --skip-bundle --dev
      create  
      create  README
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/mailers
      create  app/models
      create  app/views/layouts/application.html.erb
      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/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.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/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  public/images
      create  public/images/rails.png
      create  public/stylesheets
      create  public/stylesheets/.gitkeep
      create  public/javascripts
      create  public/javascripts/application.js
      create  public/javascripts/controls.js
      create  public/javascripts/dragdrop.js
      create  public/javascripts/effects.js
      create  public/javascripts/prototype.js
      create  public/javascripts/rails.js
      create  script
      create  script/rails
      create  test
      create  test/fixtures
      create  test/functional
      create  test/integration
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  test/unit
      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.9.2.2) 
Using abstract (1.0.0) 
Using activesupport (3.0.15) 
Using builder (2.1.2) 
Using i18n (0.5.0) 
Using activemodel (3.0.15) 
Using erubis (2.6.6) 
Using rack (1.2.5) 
Using rack-mount (0.6.14) 
Using rack-test (0.5.7) 
Using tzinfo (0.3.33) 
Using actionpack (3.0.15) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.2.19) 
Using actionmailer (3.0.15) 
Using braintree (2.16.0) 
Using activemerchant (1.10.0) 
Using arel (2.0.10) 
Using activerecord (3.0.15) 
Using activeresource (3.0.15) 
Using bundler (1.1.3) 
Using highline (1.6.13) 
Using net-ssh (2.5.2) 
Using net-scp (1.0.4) 
Using net-sftp (2.0.5) 
Using net-ssh-gateway (1.1.0) 
Using capistrano (2.12.0) 
Using haml (3.1.6) 
Using htmlentities (4.3.1) 
Using json (1.7.3) 
Using rdoc (3.12) 
Using thor (0.14.6) 
Using railties (3.0.15) 
Using rails (3.0.15) 
Using jquery-rails (0.2.7) 
Using minitest (3.2.0) 
Using mysql (2.8.1) 
Using sqlite3 (1.3.6) 
Using test-unit (2.5.0) 
Using will_paginate (3.0.3) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
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/edition3/data/routing/* config
`/home/rubys/git/awdwr/edition3/data/routing/routes.rb' -> `config/routes.rb'
`/home/rubys/git/awdwr/edition3/data/routing/routes_with_conditions.rb' -> `config/routes_with_conditions.rb'
`/home/rubys/git/awdwr/edition3/data/routing/routes_with_names.rb' -> `config/routes_with_names.rb'
`/home/rubys/git/awdwr/edition3/data/routing/routing_conditions_test.rb' -> `config/routing_conditions_test.rb'
`/home/rubys/git/awdwr/edition3/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
rake test
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from ./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 ./config/routes_with_conditions.rb:1)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/edition3/work-30/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 /home/rubys/git/awdwr/edition3/work-30/routing/config/routes.rb:3)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from ./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 ./config/routes.rb:3)
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from ./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 ./config/routes_with_conditions.rb:1)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from ./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 ./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 test_alternate_routing at /home/rubys/git/awdwr/edition3/work-30/routing/test/unit/routing_test.rb:81)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from ./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 ./config/routes_with_conditions.rb:1)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from ./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 ./config/routes.rb:3)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from ./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 ./config/routes_with_conditions.rb:1)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from ./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 ./config/routes_with_conditions.rb:1)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from ./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 ./config/routes.rb:3)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from ./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 ./config/routes_with_conditions.rb:1)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from ./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 ./config/routes.rb:3)
Started
 
 
Finished in 0.37494 seconds.
 
5 tests, 29 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
0% passed
 
13.34 tests/s, 77.35 assertions/s
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from ./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 ./config/routes_with_conditions.rb:1)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from /home/rubys/git/awdwr/edition3/work-30/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 /home/rubys/git/awdwr/edition3/work-30/routing/config/routes.rb:3)
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
 
 
Finished in 0.30438 seconds.
 
2 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
0% passed
 
6.57 tests/s, 6.57 assertions/s

21.2 Routing Requests 20 ActiveRecord: Object Life Cycle