The Depot Application

The Depot Application

Table of Contents

Development Log

ruby /home/rubys/git/rails/railties/bin/rails -v
Rails 3.0.pre
/home/rubys/.rvm/ruby-1.9.1-phead/bin/ruby -v
ruby 1.9.2dev (2009-09-16 trunk 24965) [x86_64-linux]
gem -v
1.3.5

4 Instant Gratification

erb -r erbshim -T - < /home/rubys/git/awdwr/data/code/erb/ex1.html.erb |  
         sed 's/<!--.*-->//'
<ul>
  <li>Addition: 3 </li>
  <li>Concatenation: cowboy </li>
  <li>Time in one hour:  2009-09-16 08:27:22 -0400 </li>
</ul>
erb -r erbshim -T - < /home/rubys/git/awdwr/data/code/erb/ex2.html.erb | 
         sed 's/<!--.*-->//'
 
Ho!<br />
 
Ho!<br />
 
Ho!<br />
 
Merry Christmas!
erb -r erbshim -T - < /home/rubys/git/awdwr/data/code/erb/ex2a.html.erb | 
         sed 's/<!--.*-->//'
Ho!<br />
Ho!<br />
Ho!<br />
 
Merry Christmas!
sed 's/-%>\n/%>/' < /home/rubys/git/awdwr/data/code/erb/ex2b.html.erb |  
         erb -r erbshim -T - | sed 's/<!--.*-->//'
Ho!<br />
Ho!<br />
Ho!<br />
Merry Christmas!

6.1 Iteration A1: Getting Something Running

ruby /home/rubys/git/rails/railties/bin/rails depot
      create  
      create  Rakefile
      create  README
      create  app
      create  app/helpers/application_helper.rb
      create  app/controllers/application_controller.rb
      create  app/models
      create  app/views/layouts
      create  config
      create  config/routes.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/test.rb
      create  config/environments/production.rb
      create  config/environments/development.rb
      create  config/initializers
      create  config/initializers/mime_types.rb
      create  config/initializers/session_store.rb
      create  config/initializers/inflections.rb
      create  config/initializers/new_rails_defaults.rb
      create  config/initializers/backtrace_silencers.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  log
      create  log/server.log
      create  log/production.log
      create  log/development.log
      create  log/test.log
      create  public
      create  public/422.html
      create  public/index.html
      create  public/favicon.ico
      create  public/robots.txt
      create  public/500.html
      create  public/404.html
      create  public/images
      create  public/images/rails.png
      create  public/stylesheets
       exist  public/stylesheets
      create  public/javascripts
      create  public/javascripts/dragdrop.js
      create  public/javascripts/effects.js
      create  public/javascripts/controls.js
      create  public/javascripts/prototype.js
      create  public/javascripts/application.js
      create  script
      create  script/server
      create  script/dbconsole
      create  script/destroy
      create  script/console
      create  script/performance/benchmarker
      create  script/performance/profiler
      create  script/plugin
      create  script/generate
      create  script/runner
      create  script/about
      create  test
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  test/fixtures
      create  test/integration
      create  test/functional
      create  test/unit
      create  tmp
      create  tmp/sessions
      create  tmp/sockets
      create  tmp/cache
      create  tmp/pids
      create  vendor/plugins
ln -s /home/rubys/git/rails vendor/rails
edit config/environments/development.rb
# Settings specified here will take precedence over those in config/environment.rb
 
# In the development environment your application's code is reloaded on
# every request.  This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
 
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
 
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_view.debug_rjs                         = true
config.action_controller.perform_caching             = false
 
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
 
config.logger = Logger.new(config.log_path, 2, 10.kilobytes)

6.2 Creating the Products Model and Maintenance Application

ls -p
app/
config/
db/
doc/
lib/
log/
public/
Rakefile
README
script/
test/
tmp/
vendor/
ruby script/generate scaffold product title:string description:text image_url:string
racc/parser.rb:33: warning: already initialized constant Racc_Runtime_Version
racc/parser.rb:34: warning: already initialized constant Racc_Runtime_Revision
racc/parser.rb:36: warning: already initialized constant Racc_Runtime_Core_Version_R
racc/parser.rb:37: warning: already initialized constant Racc_Runtime_Core_Revision_R
racc/parser.rb:41: warning: already initialized constant Racc_Runtime_Core_Revision_C
racc/parser.rb:49: warning: already initialized constant Racc_Main_Parsing_Routine
racc/parser.rb:50: warning: already initialized constant Racc_YY_Parse_Method
racc/parser.rb:51: warning: already initialized constant Racc_Runtime_Core_Version
racc/parser.rb:52: warning: already initialized constant Racc_Runtime_Core_Revision
racc/parser.rb:53: warning: already initialized constant Racc_Runtime_Type
      invoke  active_record
      create    db/migrate/20090916112725_create_products.rb
      create    app/models/product.rb
      invoke    test_unit
      create      test/unit/product_test.rb
      create      test/fixtures/products.yml
       route  map.resources :products
      invoke  scaffold_controller
      create    app/controllers/products_controller.rb
      invoke    erb
      create      app/views/products
      create      app/views/products/index.html.erb
      create      app/views/products/edit.html.erb
      create      app/views/products/show.html.erb
      create      app/views/products/new.html.erb
      create      app/views/products/_form.html.erb
      create      app/views/layouts/products.html.erb
      invoke    test_unit
      create      test/functional/products_controller_test.rb
      invoke    helper
      create      app/helpers/products_helper.rb
      invoke      test_unit
      create        test/unit/helpers/products_helper_test.rb
      invoke  stylesheets
      create    public/stylesheets/scaffold.css
rake db:migrate
mv 20090916112725_create_products.rb 20080601000001_create_products.rb
(in /home/rubys/git/awdwr/work/depot)
==  CreateProducts: migrating =================================================
-- create_table(:products)
   -> 0.0011s
==  CreateProducts: migrated (0.0012s) ========================================
 
sqlite3> select version from schema_migrations
version = 20080601000001

Start the server.

edit app/views/products/_form.html.erb
<% form_for(@product) do |f| %>
  <%= f.error_messages %>
 
  <div class="field">
    <%= f.label :title %><br />
    <%= f.text_field :title %>
  </div>
  <div class="field">
    <%= f.label :description %><br />
    <%= f.text_area :description, :rows => 6 %>
  </div>
  <div class="field">
    <%= f.label :image_url %><br />
    <%= f.text_field :image_url %>
  </div>
  <div class="actions">
    <% if @product.new_record? %>
      <%= f.submit 'Create' %>
    <% else %>
      <%= f.submit 'Update' %>
    <% end %>
  </div>
<% end %>
get /products

Listing products

Title Description Image url

New product
get /products/new

New product




Back
post /products
You are being redirected.
get http://127.0.0.1:3000/products/1

Title: Pragmatic Version Control

Description: <p> This book is a recipe-based approach to using Subversion that will get you up and running quickly---and correctly. All projects need version control: it's a foundational piece of any project's infrastructure. Yet half of all project teams in the U.S. dont use any version control at all. Many others dont use it well, and end up experiencing time-consuming problems. </p>

Image url: /images/svn.jpg

Edit | Back
get /products

Listing products

Title Description Image url
Pragmatic Version Control <p> This book is a recipe-based approach to using Subversion that will get you up and running quickly---and correctly. All projects need version control: it's a foundational piece of any project's infrastructure. Yet half of all project teams in the U.S. dont use any version control at all. Many others dont use it well, and end up experiencing time-consuming problems. </p> /images/svn.jpg Show Edit Destroy

New product
sqlite3 db/development.sqlite3 .schema
CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "description" text, "image_url" varchar(255), "created_at" datetime, "updated_at" datetime);
CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL);
CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version");
rake test
/home/rubys/.rvm/ruby-1.9.1-phead/bin/ruby -I"lib:test" "/home/rubys/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/helpers/products_helper_test.rb" "test/unit/product_test.rb" 
(in /home/rubys/git/awdwr/work/depot)
racc/parser.rb:33: warning: already initialized constant Racc_Runtime_Version
racc/parser.rb:34: warning: already initialized constant Racc_Runtime_Revision
racc/parser.rb:36: warning: already initialized constant Racc_Runtime_Core_Version_R
racc/parser.rb:37: warning: already initialized constant Racc_Runtime_Core_Revision_R
racc/parser.rb:41: warning: already initialized constant Racc_Runtime_Core_Revision_C
racc/parser.rb:49: warning: already initialized constant Racc_Main_Parsing_Routine
racc/parser.rb:50: warning: already initialized constant Racc_YY_Parse_Method
racc/parser.rb:51: warning: already initialized constant Racc_Runtime_Core_Version
racc/parser.rb:52: warning: already initialized constant Racc_Runtime_Core_Revision
racc/parser.rb:53: warning: already initialized constant Racc_Runtime_Type
Loaded suite /home/rubys/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.
Finished in 0.061769 seconds.
 
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
/home/rubys/.rvm/ruby-1.9.1-phead/bin/ruby -I"lib:test" "/home/rubys/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/functional/products_controller_test.rb" 
racc/parser.rb:33: warning: already initialized constant Racc_Runtime_Version
racc/parser.rb:34: warning: already initialized constant Racc_Runtime_Revision
racc/parser.rb:36: warning: already initialized constant Racc_Runtime_Core_Version_R
racc/parser.rb:37: warning: already initialized constant Racc_Runtime_Core_Revision_R
racc/parser.rb:41: warning: already initialized constant Racc_Runtime_Core_Revision_C
racc/parser.rb:49: warning: already initialized constant Racc_Main_Parsing_Routine
racc/parser.rb:50: warning: already initialized constant Racc_YY_Parse_Method
racc/parser.rb:51: warning: already initialized constant Racc_Runtime_Core_Version
racc/parser.rb:52: warning: already initialized constant Racc_Runtime_Core_Revision
racc/parser.rb:53: warning: already initialized constant Racc_Runtime_Type
Loaded suite /home/rubys/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.......
Finished in 0.176253 seconds.
 
7 tests, 10 assertions, 0 failures, 0 errors, 0 skips
/home/rubys/.rvm/ruby-1.9.1-phead/bin/ruby -I"lib:test" "/home/rubys/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb"  

6.3 Iteration A2: Add a Missing Column

ruby script/generate migration add_price_to_product price:decimal
racc/parser.rb:33: warning: already initialized constant Racc_Runtime_Version
racc/parser.rb:34: warning: already initialized constant Racc_Runtime_Revision
racc/parser.rb:36: warning: already initialized constant Racc_Runtime_Core_Version_R
racc/parser.rb:37: warning: already initialized constant Racc_Runtime_Core_Revision_R
racc/parser.rb:41: warning: already initialized constant Racc_Runtime_Core_Revision_C
racc/parser.rb:49: warning: already initialized constant Racc_Main_Parsing_Routine
racc/parser.rb:50: warning: already initialized constant Racc_YY_Parse_Method
racc/parser.rb:51: warning: already initialized constant Racc_Runtime_Core_Version
racc/parser.rb:52: warning: already initialized constant Racc_Runtime_Core_Revision
racc/parser.rb:53: warning: already initialized constant Racc_Runtime_Type
      invoke  active_record
      create    db/migrate/20090916112743_add_price_to_product.rb
cat db/migrate/20090916112743_add_price_to_product.rb
class AddPriceToProduct < ActiveRecord::Migration
  def self.up
    add_column :products, :price, :decimal
  end
 
  def self.down
    remove_column :products, :price
  end
end
edit db/migrate/20090916112743_add_price_to_product.rb
class AddPriceToProduct < ActiveRecord::Migration
  def self.up
    add_column :products, :price, :decimal,
      :precision => 8, :scale => 2, :default => 0
  end
 
  def self.down
    remove_column :products, :price
  end
end
rake db:migrate
mv 20090916112743_add_price_to_product.rb 20080601000002_add_price_to_product.rb
(in /home/rubys/git/awdwr/work/depot)
==  AddPriceToProduct: migrating ==============================================
-- add_column(:products, :price, :decimal, {:precision=>8, :scale=>2, :default=>0})
   -> 0.0007s
==  AddPriceToProduct: migrated (0.0009s) =====================================
 
sqlite3 db/development.sqlite3 .schema
CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "description" text, "image_url" varchar(255), "created_at" datetime, "updated_at" datetime, "price" decimal(8,2) DEFAULT 0);
CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL);
CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version");
edit app/views/products/index.html.erb
<h1>Listing products</h1>
 
<table>
  <tr>
    <th>Title</th>
    <th>Description</th>
    <th>Image url</th>
    <th>Price</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>
 
<% @products.each do |product| %>
  <tr>
    <td><%=h product.title %></td>
    <td><%=h product.description %></td>
    <td><%=h product.image_url %></td>
    <td><%=h product.price %></td>
    <td><%= link_to 'Show', product %></td>
    <td><%= link_to 'Edit', edit_product_path(product) %></td>
    <td><%= link_to 'Destroy', product, :confirm => 'Are you sure?',
                                        :method => :delete %></td>
  </tr>
<% end %>
</table>
 
<br />
 
<%= link_to 'New product', new_product_path %>
edit app/views/products/_form.html.erb
<% form_for(@product) do |f| %>
  <%= f.error_messages %>
 
  <div class="field">
    <%= f.label :title %><br />
    <%= f.text_field :title %>
  </div>
  <div class="field">
    <%= f.label :description %><br />
    <%= f.text_area :description, :rows => 6 %>
  </div>
  <div class="field">
    <%= f.label :image_url %><br />
    <%= f.text_field :image_url %>
  </div>
  <div class="field">
    <%= f.label :price %><br />
    <%= f.text_field :price %>
  </div>
  <div class="actions">
    <% if @product.new_record? %>
      <%= f.submit 'Create' %>
    <% else %>
      <%= f.submit 'Update' %>
    <% end %>
  </div>
<% end %>
edit app/views/products/show.html.erb
<p>
  <b>Title:</b>
  <%=h @product.title %>
</p>
 
<p>
  <b>Description:</b>
  <%=h @product.description %>
</p>
 
<p>
  <b>Image url:</b>
  <%=h @product.image_url %>
</p>
 
<p>
  <b>Price:</b>
  <%=h @product.price %>
</p>
 
<%= link_to 'Edit', edit_product_path(@product) %> |
<%= link_to 'Back', products_path %>
get /products

Listing products

Title Description Image url Price
Pragmatic Version Control <p> This book is a recipe-based approach to using Subversion that will get you up and running quickly---and correctly. All projects need version control: it's a foundational piece of any project's infrastructure. Yet half of all project teams in the U.S. dont use any version control at all. Many others dont use it well, and end up experiencing time-consuming problems. </p> /images/svn.jpg 0.0 Show Edit Destroy

New product
get /products/1

Title: Pragmatic Version Control

Description: <p> This book is a recipe-based approach to using Subversion that will get you up and running quickly---and correctly. All projects need version control: it's a foundational piece of any project's infrastructure. Yet half of all project teams in the U.S. dont use any version control at all. Many others dont use it well, and end up experiencing time-consuming problems. </p>

Image url: /images/svn.jpg

Price: 0.0

Edit | Back
get /products/new

New product





Back
rake test
/home/rubys/.rvm/ruby-1.9.1-phead/bin/ruby -I"lib:test" "/home/rubys/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/helpers/products_helper_test.rb" "test/unit/product_test.rb" 
(in /home/rubys/git/awdwr/work/depot)
racc/parser.rb:33: warning: already initialized constant Racc_Runtime_Version
racc/parser.rb:34: warning: already initialized constant Racc_Runtime_Revision
racc/parser.rb:36: warning: already initialized constant Racc_Runtime_Core_Version_R
racc/parser.rb:37: warning: already initialized constant Racc_Runtime_Core_Revision_R
racc/parser.rb:41: warning: already initialized constant Racc_Runtime_Core_Revision_C
racc/parser.rb:49: warning: already initialized constant Racc_Main_Parsing_Routine
racc/parser.rb:50: warning: already initialized constant Racc_YY_Parse_Method
racc/parser.rb:51: warning: already initialized constant Racc_Runtime_Core_Version
racc/parser.rb:52: warning: already initialized constant Racc_Runtime_Core_Revision
racc/parser.rb:53: warning: already initialized constant Racc_Runtime_Type
Loaded suite /home/rubys/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.
Finished in 0.053196 seconds.
 
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
/home/rubys/.rvm/ruby-1.9.1-phead/bin/ruby -I"lib:test" "/home/rubys/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/functional/products_controller_test.rb" 
racc/parser.rb:33: warning: already initialized constant Racc_Runtime_Version
racc/parser.rb:34: warning: already initialized constant Racc_Runtime_Revision
racc/parser.rb:36: warning: already initialized constant Racc_Runtime_Core_Version_R
racc/parser.rb:37: warning: already initialized constant Racc_Runtime_Core_Revision_R
racc/parser.rb:41: warning: already initialized constant Racc_Runtime_Core_Revision_C
racc/parser.rb:49: warning: already initialized constant Racc_Main_Parsing_Routine
racc/parser.rb:50: warning: already initialized constant Racc_YY_Parse_Method
racc/parser.rb:51: warning: already initialized constant Racc_Runtime_Core_Version
racc/parser.rb:52: warning: already initialized constant Racc_Runtime_Core_Revision
racc/parser.rb:53: warning: already initialized constant Racc_Runtime_Type
Loaded suite /home/rubys/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.......
Finished in 0.177226 seconds.
 
7 tests, 10 assertions, 0 failures, 0 errors, 0 skips
/home/rubys/.rvm/ruby-1.9.1-phead/bin/ruby -I"lib:test" "/home/rubys/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb"  
edit app/views/products/show.html.erb
<p>
  <b>Title:</b>
  <%=h @product.title %>
</p>
 
<p>
  <b>Description:</b>
  <%= @product.description %>
</p>
 
<p>
  <b>Image url:</b>
  <%=h @product.image_url %>
</p>
 
<p>
  <b>Price:</b>
  <%=h @product.price %>
</p>
 
<%= link_to 'Edit', edit_product_path(@product) %> |
<%= link_to 'Back', products_path %>
get /products/1

Title: Pragmatic Version Control

Description:

This book is a recipe-based approach to using Subversion that will get you up and running quickly---and correctly. All projects need version control: it's a foundational piece of any project's infrastructure. Yet half of all project teams in the U.S. dont use any version control at all. Many others dont use it well, and end up experiencing time-consuming problems.

Image url: /images/svn.jpg

Price: 0.0

Edit | Back

6.4 Iteration A3: Validate!

edit app/models/product.rb
class Product < ActiveRecord::Base
  validates_presence_of :title, :description, :image_url
  validates_numericality_of :price
  validate :price_must_be_at_least_a_cent
  validates_uniqueness_of :title
  validates_format_of :image_url, :allow_blank => true,
                      :with    => %r{\.(gif|jpg|png)$}i,
                      :message => 'must be a URL for GIF, JPG ' +
                                  'or PNG image.'
 
protected
  def price_must_be_at_least_a_cent
    errors.add(:price, 'should be at least 0.01') if price.nil? ||
                       price < 0.00
  end
 
end
get /products/new

New product





Back
post /products
  • product[price] => 0.0

New product

3 errors prohibited this product from being saved

There were problems with the following fields:

  • Title can't be blank
  • Description can't be blank
  • Image url can't be blank




Back
get /products/new

New product





Back
post /products
  • product[title] => Pragmatic Unit Testing
  • product[description] => A true masterwork. Comparable to Kafka at his funniest, or Marx during his slapstick period. Move over, Tolstoy, there's a new funster in town.
  • product[image_url] => /images/utj.jpg
  • product[price] => wibble

New product

1 error prohibited this product from being saved

There were problems with the following fields:

  • Price is not a number




Back
edit app/models/product.rb
class Product < ActiveRecord::Base
  validates_presence_of :title, :description, :image_url
  validates_numericality_of :price
  validate :price_must_be_at_least_a_cent
  validates_uniqueness_of :title
  validates_format_of :image_url,
                      :with    => %r{\.(gif|jpg|png)$}i,
                      :message => 'must be a URL for GIF, JPG ' +
                                  'or PNG image.'
 
protected
  def price_must_be_at_least_a_cent
    errors.add(:price, 'should be at least 0.01') if price.nil? ||
                       price < 0.01
  end
 
end
edit app/views/layouts/products.html.erb

6.5 Iteration A4: Making Prettier Listings

edit db/migrate/003_add_test_data.rb
class AddTestData < ActiveRecord::Migration
  def self.up
    Product.delete_all
    Product.create(:title => 'Pragmatic Version Control',
      :description =>
      %{<p>
         This book is a recipe-based approach to using Subversion that will 
         get you up and running quickly---and correctly. All projects need
         version control: it's a foundational piece of any project's 
         infrastructure. Yet half of all project teams in the U.S. don't use
         any version control at all. Many others don't use it well, and end 
         up experiencing time-consuming problems.
      </p>},
    :image_url => '/images/svn.jpg',
    :price => 28.50)
    # . . .
  end
 
  def self.down
    Product.delete_all
  end
end
rake db:migrate
mv 003_add_test_data.rb 20080601000003_add_test_data.rb
(in /home/rubys/git/awdwr/work/depot)
==  AddTestData: migrating ====================================================
==  AddTestData: migrated (0.0141s) ===========================================
 
edit app/views/layouts/products.html.erb
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <title>Products: <%= controller.action_name %></title>
  <%= stylesheet_link_tag 'scaffold', 'depot' %>
</head>
edit app/views/products/index.html.erb
<div id="product-list">
  <h1>Listing products</h1>
 
  <table>
  <% for product in @products %>
    <tr class="<%= cycle('list-line-odd', 'list-line-even') %>">
 
      <td>
        <%= image_tag product.image_url, :class => 'list-image' %>
      </td>
 
      <td class="list-description">
        <dl>
          <dt><%=h product.title %></dt>
          <dd><%=h truncate(product.description.gsub(/<.*?>/,''),
                 :length => 80) %></dd>
        </dl>
      </td>
 
      <td class="list-actions">
        <%= link_to 'Show', product %><br/>
        <%= link_to 'Edit', edit_product_path(product) %><br/>
        <%= link_to 'Destroy', product, 
                    :confirm => 'Are you sure?',
                    :method => :delete %>
      </td>
    </tr>
  <% end %>
  </table>
</div>
 
<br />
 
<%= link_to 'New product', new_product_path %>
cp -v /home/rubys/git/awdwr/data/images/* public/images/
`/home/rubys/git/awdwr/data/images/auto.jpg' -> `public/images/auto.jpg'
`/home/rubys/git/awdwr/data/images/logo.png' -> `public/images/logo.png'
`/home/rubys/git/awdwr/data/images/rails.png' -> `public/images/rails.png'
`/home/rubys/git/awdwr/data/images/svn.jpg' -> `public/images/svn.jpg'
`/home/rubys/git/awdwr/data/images/utc.jpg' -> `public/images/utc.jpg'
cp -v /home/rubys/git/awdwr/data/depot.css public/stylesheets
`/home/rubys/git/awdwr/data/depot.css' -> `public/stylesheets/depot.css'
get /products

Listing products

Auto
Pragmatic Project Automation
Pragmatic Project Automation shows you how to improve the con...
Show
Edit
Destroy
Svn
Pragmatic Version Control
This book is a recipe-based approach to using Subversion that will ...
Show
Edit
Destroy
Utc
Pragmatic Unit Testing (C#)
Pragmatic programmers use feedback to drive their development and ...
Show
Edit
Destroy

New product

7.1 Iteration B1: Create the Catalog Listing

ruby script/generate controller store index
racc/parser.rb:33: warning: already initialized constant Racc_Runtime_Version
racc/parser.rb:34: warning: already initialized constant Racc_Runtime_Revision
racc/parser.rb:36: warning: already initialized constant Racc_Runtime_Core_Version_R
racc/parser.rb:37: warning: already initialized constant Racc_Runtime_Core_Revision_R
racc/parser.rb:41: warning: already initialized constant Racc_Runtime_Core_Revision_C
racc/parser.rb:49: warning: already initialized constant Racc_Main_Parsing_Routine
racc/parser.rb:50: warning: already initialized constant Racc_YY_Parse_Method
racc/parser.rb:51: warning: already initialized constant Racc_Runtime_Core_Version
racc/parser.rb:52: warning: already initialized constant Racc_Runtime_Core_Revision
racc/parser.rb:53: warning: already initialized constant Racc_Runtime_Type
      create  app/controllers/store_controller.rb
      invoke  erb
      create    app/views/store
      create    app/views/store/index.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

Restart the server.

get /store

Store#index

Find me in app/views/store/index.html.erb

edit app/controllers/store_controller.rb
class StoreController < ApplicationController
  def index
    @products = Product.find_products_for_sale
  end
 
end
edit app/models/product.rb
class Product < ActiveRecord::Base
 
  def self.find_products_for_sale
    find(:all, :order => "title")
  end
 
  # validation stuff...
 
 
  validates_presence_of :title, :description, :image_url
  validates_numericality_of :price
  validate :price_must_be_at_least_a_cent
  validates_uniqueness_of :title
  validates_format_of :image_url,
                      :with    => %r{\.(gif|jpg|png)$}i,
                      :message => 'must be a URL for GIF, JPG ' +
                                  'or PNG image.'
 
protected
  def price_must_be_at_least_a_cent
    errors.add(:price, 'should be at least 0.01') if price.nil? ||
                       price < 0.01
  end
 
end
edit app/views/store/index.html.erb
<h1>Your Pragmatic Catalog</h1>
 
<% for product in @products -%>
  <div class="entry">
    <%= image_tag(product.image_url) %>
    <h3><%=h product.title %></h3>
    <%= product.description %>
    <div class="price-line">
    <span class="price"><%= product.price %></span>
    </div>
  </div>
<% end %>
get /store

Your Pragmatic Catalog

Auto

Pragmatic Project Automation

Pragmatic Project Automation shows you how to improve the consistency and repeatability of your project's procedures using automation to reduce risk and errors.

Simply put, we're going to put this thing called a computer to work for you doing the mundane (but important) project stuff. That means you'll have more time and energy to do the really exciting---and difficult---stuff, like writing quality code.

29.95
Utc

Pragmatic Unit Testing (C#)

Pragmatic programmers use feedback to drive their development and personal processes. The most valuable feedback you can get while coding comes from unit testing.

Without good tests in place, coding can become a frustrating game of "whack-a-mole." That's the carnival game where the player strikes at a mechanical mole; it retreats and another mole pops up on the opposite side of the field. The moles pop up and down so fast that you end up flailing your mallet helplessly as the moles continue to pop up where you least expect them.

27.75
Svn

Pragmatic Version Control

This book is a recipe-based approach to using Subversion that will get you up and running quickly---and correctly. All projects need version control: it's a foundational piece of any project's infrastructure. Yet half of all project teams in the U.S. don't use any version control at all. Many others don't use it well, and end up experiencing time-consuming problems.

28.5

7.2 Iteration B2: Add a Page Layout

edit app/views/layouts/store.html.erb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <title>Pragprog Books Online Store</title>
  <%= stylesheet_link_tag "depot", :media => "all" %><!-- <label id="code.slt"/> -->
</head>
<body id="store">
  <div id="banner">
    <%= image_tag("logo.png") %>
    <%= @page_title || "Pragmatic Bookshelf" %><!-- <label id="code.depot.e.title"/> -->
  </div>
  <div id="columns">
    <div id="side">
      <a href="http://www....">Home</a><br />
      <a href="http://www..../faq">Questions</a><br />
      <a href="http://www..../news">News</a><br />
      <a href="http://www..../contact">Contact</a><br />
    </div>
    <div id="main">
      <%= yield :layout %><!-- <label id="code.depot.e.include"/> -->
    </div>
  </div>
</body>
</html>
edit public/stylesheets/depot.css
/* Styles for main page */
 
#banner {
  background: #9c9;
  padding-top: 10px;
  padding-bottom: 10px;
  border-bottom: 2px solid;
  font: small-caps 40px/40px "Times New Roman", serif;
  color: #282;
  text-align: center;
}
 
#banner img {
  float: left;
}
 
#columns {
  background: #141;
}
 
#main {
  margin-left: 13em;
  padding-top: 4ex;
  padding-left: 2em;
  background: white;
}
 
#side {
  float: left;
  padding-top: 1em;
  padding-left: 1em;
  padding-bottom: 1em;
  width: 12em;
  background: #141;
}
 
#side a {
  color: #bfb;
  font-size: small;
}
get /store

Your Pragmatic Catalog

Auto

Pragmatic Project Automation

Pragmatic Project Automation shows you how to improve the consistency and repeatability of your project's procedures using automation to reduce risk and errors.

Simply put, we're going to put this thing called a computer to work for you doing the mundane (but important) project stuff. That means you'll have more time and energy to do the really exciting---and difficult---stuff, like writing quality code.

29.95
Utc

Pragmatic Unit Testing (C#)

Pragmatic programmers use feedback to drive their development and personal processes. The most valuable feedback you can get while coding comes from unit testing.

Without good tests in place, coding can become a frustrating game of "whack-a-mole." That's the carnival game where the player strikes at a mechanical mole; it retreats and another mole pops up on the opposite side of the field. The moles pop up and down so fast that you end up flailing your mallet helplessly as the moles continue to pop up where you least expect them.

27.75
Svn

Pragmatic Version Control

This book is a recipe-based approach to using Subversion that will get you up and running quickly---and correctly. All projects need version control: it's a foundational piece of any project's infrastructure. Yet half of all project teams in the U.S. don't use any version control at all. Many others don't use it well, and end up experiencing time-consuming problems.

28.5

7.3 Iteration B3: Use a Helper to Format the Price

edit app/views/store/index.html.erb
<h1>Your Pragmatic Catalog</h1>
 
<% for product in @products -%>
  <div class="entry">
    <%= image_tag(product.image_url) %>
    <h3><%=h product.title %></h3>
    <%= product.description %>
    <div class="price-line">
    <span class="price"><%= number_to_currency(product.price) %></span>
    </div>
  </div>
<% end %>
get /store

Your Pragmatic Catalog

Auto

Pragmatic Project Automation

Pragmatic Project Automation shows you how to improve the consistency and repeatability of your project's procedures using automation to reduce risk and errors.

Simply put, we're going to put this thing called a computer to work for you doing the mundane (but important) project stuff. That means you'll have more time and energy to do the really exciting---and difficult---stuff, like writing quality code.

$29.95
Utc

Pragmatic Unit Testing (C#)

Pragmatic programmers use feedback to drive their development and personal processes. The most valuable feedback you can get while coding comes from unit testing.

Without good tests in place, coding can become a frustrating game of "whack-a-mole." That's the carnival game where the player strikes at a mechanical mole; it retreats and another mole pops up on the opposite side of the field. The moles pop up and down so fast that you end up flailing your mallet helplessly as the moles continue to pop up where you least expect them.

$27.75
Svn

Pragmatic Version Control

This book is a recipe-based approach to using Subversion that will get you up and running quickly---and correctly. All projects need version control: it's a foundational piece of any project's infrastructure. Yet half of all project teams in the U.S. don't use any version control at all. Many others don't use it well, and end up experiencing time-consuming problems.

$28.50

7.4 Iteration B4: Linking to the Cart

edit app/views/store/index.html.erb
    <%= button_to "Add to Cart" %>
edit public/stylesheets/depot.css
#store .entry form, #store .entry form div {
  display: inline;
}
get /store

Your Pragmatic Catalog

Auto

Pragmatic Project Automation

Pragmatic Project Automation shows you how to improve the consistency and repeatability of your project's procedures using automation to reduce risk and errors.

Simply put, we're going to put this thing called a computer to work for you doing the mundane (but important) project stuff. That means you'll have more time and energy to do the really exciting---and difficult---stuff, like writing quality code.

$29.95
Utc

Pragmatic Unit Testing (C#)

Pragmatic programmers use feedback to drive their development and personal processes. The most valuable feedback you can get while coding comes from unit testing.

Without good tests in place, coding can become a frustrating game of "whack-a-mole." That's the carnival game where the player strikes at a mechanical mole; it retreats and another mole pops up on the opposite side of the field. The moles pop up and down so fast that you end up flailing your mallet helplessly as the moles continue to pop up where you least expect them.

$27.75
Svn

Pragmatic Version Control

This book is a recipe-based approach to using Subversion that will get you up and running quickly---and correctly. All projects need version control: it's a foundational piece of any project's infrastructure. Yet half of all project teams in the U.S. don't use any version control at all. Many others don't use it well, and end up experiencing time-consuming problems.

$28.50

8.1 Sessions

rake db:sessions:create
(in /home/rubys/git/awdwr/work/depot)
      invoke  active_record
      create    db/migrate/20090916112807_add_sessions_table.rb
rake db:migrate
mv 20090916112807_add_sessions_table.rb 20080601000004_add_sessions_table.rb
(in /home/rubys/git/awdwr/work/depot)
==  AddSessionsTable: migrating ===============================================
-- create_table(:sessions)
   -> 0.0013s
-- add_index(:sessions, :session_id)
   -> 0.0005s
-- add_index(:sessions, :updated_at)
   -> 0.0002s
==  AddSessionsTable: migrated (0.0021s) ======================================
 
sqlite3 db/development.sqlite3 .schema
CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "description" text, "image_url" varchar(255), "created_at" datetime, "updated_at" datetime, "price" decimal(8,2) DEFAULT 0);
CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL);
CREATE TABLE "sessions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "session_id" varchar(255) NOT NULL, "data" text, "created_at" datetime, "updated_at" datetime);
CREATE INDEX "index_sessions_on_session_id" ON "sessions" ("session_id");
CREATE INDEX "index_sessions_on_updated_at" ON "sessions" ("updated_at");
CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version");
edit config/initializers/session_store.rb
# Be sure to restart your server when you modify this file.
 
# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random, 
# no regular words or you'll be exposed to dictionary attacks.
ActionController::Base.session = {
  :key         => '_depot_session',
  :secret      => '7a0298e11d615f2ddcfa56ccf23cc3e553d0772f1578204686e089a94158e732050543b46670f629ef2aa9451b96f4d555fb9e8ecb59af44f511020894b692fb'
}
 
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rake db:sessions:create")
ActionController::Base.session_store = :active_record_store

Restart the server.

edit app/controllers/application_controller.rb
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
 
class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  protect_from_forgery # See ActionController::RequestForgeryProtection for details
 
  # Scrub sensitive parameters from your log
  # filter_parameter_logging :password
end
edit app/controllers/store_controller.rb
private
 
  def find_cart
    session[:cart] ||= Cart.new
  end

8.199999999999999 Iteration C1: Creating a Cart

edit app/models/cart.rb
class Cart
  attr_reader :items   # <wtf linkend="wtf.attr.accessor">attr_reader</wtf>
  
  def initialize
    @items = []
  end
  
  def add_product(product)
    @items << product
  end
end
edit app/views/store/index.html.erb
    <%= button_to "Add to Cart", :action => 'add_to_cart', :id => product %>
edit app/controllers/store_controller.rb
  def add_to_cart
    product = Product.find(params[:id]) # <label id="code.depot.f.find"/>
    @cart = find_cart                   # <label id="code.depot.f.find2"/>
    @cart.add_product(product)          # <label id="code.depot.f.add"/>
  end
get /store/add_to_cart/2

Template is missing

Missing template store/add_to_cart - {:formats=>[:"*/*"]} - partial: false.erb in view path /home/rubys/git/awdwr/work/depot/app/views

edit app/views/store/add_to_cart.html.erb
<h2>Your Pragmatic Cart</h2>
<ul>
  <% for item in @cart.items %>
    <li><%=h item.title %></li>
  <% end %>
</ul>
get /store/add_to_cart/2

Your Pragmatic Cart

  • Pragmatic Project Automation
get /store/add_to_cart/3

Your Pragmatic Cart

  • Pragmatic Project Automation
  • Pragmatic Version Control

8.300000000000001 Iteration C2: Creating a Smarter Cart

edit app/models/cart_item.rb
class CartItem
 
  attr_reader :product, :quantity
  
  def initialize(product)
    @product = product
    @quantity = 1
  end
  
  def increment_quantity
    @quantity += 1
  end
  
  def title
    @product.title
  end
  
  def price
    @product.price * @quantity
  end
end
edit app/models/cart.rb
  def add_product(product)
    current_item = @items.find {|item| item.product == product}
    if current_item
      current_item.increment_quantity
    else
      @items << CartItem.new(product)
    end
  end
edit app/views/store/add_to_cart.html.erb
<h2>Your Pragmatic Cart</h2>
<ul>
  <% for item in @cart.items %>
    <li><%= item.quantity %> &times; <%=h item.title %></li>
  <% end %>
</ul>
get /store/add_to_cart/2
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Action Controller: Exception caught</title>
  <style>
    body { background-color: #fff; color: #333; }

    
    body, p, ol, ul, td {
      font-family: verdana, arial, helvetica, sans-serif;
      font-size:   13px;
      line-height: 18px;
    }

    
    pre {
      background-color: #eee;
      padding: 10px;
      font-size: 11px;
    }

    
    a { color: #000; }
    a:visited { color: #666; }
    a:hover { color: #fff; background-color:#000; }
  </style>
</head>
<body>

    
<h1>
  NoMethodError
  
    in StoreController#add_to_cart
  
</h1>
<pre>undefined method `product' for #&lt;Product:0x000000031fae70&gt;</pre>

    

    

    
<p><code>RAILS_ROOT: /home/rubys/git/awdwr/work/depot</code></p>

    
<div id="traces">
  
    
    <a href="#" onclick="["document.getElementById('Framework-Trace').style.display='none';", "document.getElementById('Full-Trace').style.display='none';"]document.getElementById('Application-Trace').style.display='block';; return false;">Application Trace</a> |
  
    
    <a href="#" onclick="["document.getElementById('Application-Trace').style.display='none';", "document.getElementById('Full-Trace').style.display='none';"]document.getElementById('Framework-Trace').style.display='block';; return false;">Framework Trace</a> |
  
    
    <a href="#" onclick="["document.getElementById('Application-Trace').style.display='none';", "document.getElementById('Framework-Trace').style.display='none';"]document.getElementById('Full-Trace').style.display='block';; return false;">Full Trace</a> 
  

    
  
    <div id="Application-Trace" style="display: block;">
      <pre><code>/home/rubys/git/awdwr/work/depot/vendor/rails/activemodel/lib/active_model/attribute_methods.rb:240:in `method_missing'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:38:in `method_missing'
/home/rubys/git/awdwr/work/depot/app/models/cart.rb:10:in `block in add_product'
/home/rubys/git/awdwr/work/depot/app/models/cart.rb:10:in `each'
/home/rubys/git/awdwr/work/depot/app/models/cart.rb:10:in `find'
/home/rubys/git/awdwr/work/depot/app/models/cart.rb:10:in `add_product'
/home/rubys/git/awdwr/work/depot/app/controllers/store_controller.rb:11:in `add_to_cart'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/base.rb:43:in `send_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/base.rb:112:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/logger.rb:32:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/activesupport/lib/active_support/new_callbacks.rb:420:in `_run__1808272810262179749__process_action__1744376372027287746__callbacks'
/home/rubys/git/awdwr/work/depot/vendor/rails/activesupport/lib/active_support/new_callbacks.rb:405:in `_run_process_action_callbacks'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/callbacks.rb:19:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/rendering_controller.rb:42:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/compatibility.rb:77:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/flash.rb:140:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/rescuable.rb:46:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/base.rb:91:in `process'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/filter_parameter_logging.rb:69:in `process'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal.rb:72:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/rack_convenience.rb:15:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal.rb:96:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:440:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/head.rb:9:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/params_parser.rb:19:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb:146:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in `block in call'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/query_cache.rb:9:in `cache'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/query_cache.rb:28:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:363:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/rescue.rb:8:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb:35:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:8:in `synchronize'</code></pre>
    </div>
  
    <div id="Framework-Trace" style="display: none;">
      <pre><code>/home/rubys/git/awdwr/work/depot/vendor/rails/activemodel/lib/active_model/attribute_methods.rb:240:in `method_missing'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:38:in `method_missing'
/home/rubys/git/awdwr/work/depot/app/models/cart.rb:10:in `block in add_product'
/home/rubys/git/awdwr/work/depot/app/models/cart.rb:10:in `each'
/home/rubys/git/awdwr/work/depot/app/models/cart.rb:10:in `find'
/home/rubys/git/awdwr/work/depot/app/models/cart.rb:10:in `add_product'
/home/rubys/git/awdwr/work/depot/app/controllers/store_controller.rb:11:in `add_to_cart'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/base.rb:43:in `send_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/base.rb:112:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/logger.rb:32:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/activesupport/lib/active_support/new_callbacks.rb:420:in `_run__1808272810262179749__process_action__1744376372027287746__callbacks'
/home/rubys/git/awdwr/work/depot/vendor/rails/activesupport/lib/active_support/new_callbacks.rb:405:in `_run_process_action_callbacks'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/callbacks.rb:19:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/rendering_controller.rb:42:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/compatibility.rb:77:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/flash.rb:140:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/rescuable.rb:46:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/base.rb:91:in `process'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/filter_parameter_logging.rb:69:in `process'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal.rb:72:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/rack_convenience.rb:15:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal.rb:96:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:440:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/head.rb:9:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/params_parser.rb:19:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb:146:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in `block in call'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/query_cache.rb:9:in `cache'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/query_cache.rb:28:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:363:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/rescue.rb:8:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb:35:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/lock.rb:11:in `block in call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/railties/lib/rails/rack/static.rb:31:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in `block in call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `each'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/railties/lib/rails/rack/log_tailer.rb:17:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/content_length.rb:13:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/handler/webrick.rb:46:in `service'
/home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'</code></pre>
    </div>
  
    <div id="Full-Trace" style="display: none;">
      <pre><code>/home/rubys/git/awdwr/work/depot/vendor/rails/activemodel/lib/active_model/attribute_methods.rb:240:in `method_missing'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:38:in `method_missing'
/home/rubys/git/awdwr/work/depot/app/models/cart.rb:10:in `block in add_product'
/home/rubys/git/awdwr/work/depot/app/models/cart.rb:10:in `each'
/home/rubys/git/awdwr/work/depot/app/models/cart.rb:10:in `find'
/home/rubys/git/awdwr/work/depot/app/models/cart.rb:10:in `add_product'
/home/rubys/git/awdwr/work/depot/app/controllers/store_controller.rb:11:in `add_to_cart'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/base.rb:43:in `send_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/base.rb:112:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/logger.rb:32:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/activesupport/lib/active_support/new_callbacks.rb:420:in `_run__1808272810262179749__process_action__1744376372027287746__callbacks'
/home/rubys/git/awdwr/work/depot/vendor/rails/activesupport/lib/active_support/new_callbacks.rb:405:in `_run_process_action_callbacks'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/callbacks.rb:19:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/rendering_controller.rb:42:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/compatibility.rb:77:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/flash.rb:140:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/rescuable.rb:46:in `process_action'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/abstract_controller/base.rb:91:in `process'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/filter_parameter_logging.rb:69:in `process'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal.rb:72:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal/rack_convenience.rb:15:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/metal.rb:96:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:440:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/head.rb:9:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/params_parser.rb:19:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb:146:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in `block in call'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/query_cache.rb:9:in `cache'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/query_cache.rb:28:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:363:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/rescue.rb:8:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb:35:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:8:in `synchronize'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/railties/lib/rails/rack/static.rb:31:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in `block in call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `each'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `call'
/home/rubys/git/awdwr/work/depot/vendor/rails/railties/lib/rails/rack/log_tailer.rb:17:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/content_length.rb:13:in `call'
/home/rubys/.rvm/gems/ruby/1.9.1/gems/rack-1.0.0/lib/rack/handler/webrick.rb:46:in `service'
/home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'</code></pre>
    </div>
  
</div>

    

    

    

    

    
<h2 style="margin-top: 30px">Request</h2>
<p><b>Parameters</b>: <pre>{&quot;id&quot;=&gt;&quot;2&quot;}</pre></p>

    
<p><a href="#" onclick="document.getElementById('session_dump').style.display='block'; return false;">Show session dump</a></p>
<div id="session_dump" style="display:none"><pre class='debug_dump'>--- 
</pre></div>

    

    
<h2 style="margin-top: 30px">Response</h2>
<p><b>Headers</b>: <pre>None</pre></p>

    

    

    
</body>
</html>
#<REXML::UndefinedNamespaceException: Undefined prefix internal found>
  /home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/rexml/parsers/baseparser.rb:419:in `block in pull'
  /home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/set.rb:211:in `block in each'
  /home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/set.rb:211:in `each_key'
  /home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/set.rb:211:in `each'
  /home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/rexml/parsers/baseparser.rb:417:in `pull'
  /home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/rexml/parsers/treeparser.rb:22:in `parse'
  /home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/rexml/document.rb:228:in `build'
  /home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/rexml/document.rb:43:in `initialize'
  /home/rubys/git/awdwr/gorp.rb:226:in `new'
  /home/rubys/git/awdwr/gorp.rb:226:in `xhtmlparse'
  /home/rubys/git/awdwr/gorp.rb:310:in `snap'
  /home/rubys/git/awdwr/gorp.rb:380:in `block in post'
  /home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/net/http.rb:564:in `start'
  /home/rubys/.rvm/ruby-1.9.1-phead/lib/ruby/1.9.1/net/http.rb:453:in `start'
  /home/rubys/git/awdwr/gorp.rb:376:in `post'
  makedepot.rb:463:in `block in <main>'
  /home/rubys/git/awdwr/gorp.rb:588:in `call'
  /home/rubys/git/awdwr/gorp.rb:588:in `block (4 levels) in <top (required)>'
  /home/rubys/git/awdwr/gorp.rb:584:in `each'
  /home/rubys/git/awdwr/gorp.rb:584:in `block (3 levels) in <top (required)>'
  /home/rubys/.rvm/gems/ruby/1.9.1/gems/builder-2.1.2/lib/builder/xmlbase.rb:134:in `call'
  /home/rubys/.rvm/gems/ruby/1.9.1/gems/builder-2.1.2/lib/builder/xmlbase.rb:134:in `_nested_structures'
  /home/rubys/.rvm/gems/ruby/1.9.1/gems/builder-2.1.2/lib/builder/xmlbase.rb:58:in `method_missing'
  /home/rubys/git/awdwr/gorp.rb:549:in `block (2 levels) in <top (required)>'
  /home/rubys/.rvm/gems/ruby/1.9.1/gems/builder-2.1.2/lib/builder/xmlbase.rb:134:in `call'
  /home/rubys/.rvm/gems/ruby/1.9.1/gems/builder-2.1.2/lib/builder/xmlbase.rb:134:in `_nested_structures'
  /home/rubys/.rvm/gems/ruby/1.9.1/gems/builder-2.1.2/lib/builder/xmlbase.rb:58:in `method_missing'
  /home/rubys/git/awdwr/gorp.rb:517:in `block in <top (required)>'