The Depot Application

8.3 Iteration C2: Creating a Smarter Cart 8.1 Sessions

8.2 Iteration C1: Creating a Cart

</Missing template store\/add_to_cart/> expected but was
<"RAILS_ROOT: /home/rubys/git/awdwr/edition3/work-192-23/depot">.

Traceback:
  /home/rubys/git/awdwr/edition3/work-192-23/vendor/rails/actionpack/lib/action_controller/assertions/selector_assertions.rb:307:in `assert_select'
  /home/rubys/git/awdwr/edition3/checkdepot.rb:111:in `block in <class:DepotTest>'
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

ActiveRecord::StatementInvalid in StoreController#add_to_cart

Could not find table 'products'

RAILS_ROOT: /home/rubys/git/awdwr/edition3/work-192-23/depot

Application Trace | Framework Trace | Full Trace
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:29:in `block in table_structure'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:28:in `tap'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:28:in `table_structure'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:228:in `columns'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:1305:in `columns'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:1313:in `columns_hash'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:1612:in `find_one'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:1603:in `find_from_ids'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:620:in `find'
/home/rubys/git/awdwr/edition3/work-192-23/depot/app/controllers/store_controller.rb:9:in `add_to_cart'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/base.rb:1333:in `perform_action'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_with_filters'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `block in perform_action_with_benchmark'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `block in ms'
/home/rubys/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_with_benchmark'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/rescue.rb:160:in `perform_action_with_rescue'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/flash.rb:151:in `perform_action_with_flash'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/base.rb:532:in `process'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process_with_filters'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/base.rb:391:in `process'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/base.rb:386:in `call'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:438:in `call'

Request

Parameters:

{"id"=>"2"}

Show session dump

Response

Headers:

{"Cache-Control"=>"no-cache",
 "Content-Type"=>""}
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

ActiveRecord::StatementInvalid in StoreController#add_to_cart

Could not find table 'products'

RAILS_ROOT: /home/rubys/git/awdwr/edition3/work-192-23/depot

Application Trace | Framework Trace | Full Trace
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:29:in `block in table_structure'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:28:in `tap'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:28:in `table_structure'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:228:in `columns'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:1305:in `columns'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:1313:in `columns_hash'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:1612:in `find_one'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:1603:in `find_from_ids'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:620:in `find'
/home/rubys/git/awdwr/edition3/work-192-23/depot/app/controllers/store_controller.rb:9:in `add_to_cart'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/base.rb:1333:in `perform_action'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_with_filters'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `block in perform_action_with_benchmark'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `block in ms'
/home/rubys/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_with_benchmark'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/rescue.rb:160:in `perform_action_with_rescue'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/flash.rb:151:in `perform_action_with_flash'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/base.rb:532:in `process'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process_with_filters'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/base.rb:391:in `process'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/base.rb:386:in `call'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:438:in `call'

Request

Parameters:

{"id"=>"2"}

Show session dump

Response

Headers:

{"Cache-Control"=>"no-cache",
 "Content-Type"=>""}
get /store/add_to_cart/3

ActiveRecord::StatementInvalid in StoreController#add_to_cart

Could not find table 'products'

RAILS_ROOT: /home/rubys/git/awdwr/edition3/work-192-23/depot

Application Trace | Framework Trace | Full Trace
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:29:in `block in table_structure'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:28:in `tap'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:28:in `table_structure'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:228:in `columns'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:1305:in `columns'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:1313:in `columns_hash'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:1612:in `find_one'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:1603:in `find_from_ids'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activerecord/lib/active_record/base.rb:620:in `find'
/home/rubys/git/awdwr/edition3/work-192-23/depot/app/controllers/store_controller.rb:9:in `add_to_cart'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/base.rb:1333:in `perform_action'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_with_filters'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `block in perform_action_with_benchmark'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `block in ms'
/home/rubys/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_with_benchmark'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/rescue.rb:160:in `perform_action_with_rescue'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/flash.rb:151:in `perform_action_with_flash'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/base.rb:532:in `process'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process_with_filters'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/base.rb:391:in `process'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/base.rb:386:in `call'
/home/rubys/git/awdwr/edition3/work-192-23/depot/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:438:in `call'

Request

Parameters:

{"id"=>"3"}

Show session dump

Response

Headers:

{"Cache-Control"=>"no-cache",
 "Content-Type"=>""}

8.3 Iteration C2: Creating a Smarter Cart 8.1 Sessions