From: Neil Smith Date: Fri, 30 Jan 2009 11:56:47 +0000 (+0000) Subject: Finished chapter 6 X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=cf29841dca2a4ba6313a99576d56e238b700a158;p=depot.git Finished chapter 6 --- diff --git a/app/models/product.rb b/app/models/product.rb index 077a819..05ac26e 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,2 +1,14 @@ class Product < ActiveRecord::Base + validates_presence_of :title, :description, :image_url + validates_numericality_of :price + validate :price_must_be_at_least_a_penny + validates_uniqueness_of :title + validates_format_of :image_url, + :with => %r{\.(gif|jpg|png)$}i, + :message => 'must be a URL for a GIF, JPG, or PNG image.' + +protected + def price_must_be_at_least_a_penny + errors.add(:price, 'should be at least 0.01') if price.nil? || price < 0.01 + end end diff --git a/app/views/layouts/products.html.erb b/app/views/layouts/products.html.erb index b9f60be..07fed7f 100644 --- a/app/views/layouts/products.html.erb +++ b/app/views/layouts/products.html.erb @@ -5,7 +5,7 @@ Products: <%= controller.action_name %> - <%= stylesheet_link_tag 'scaffold' %> + <%= stylesheet_link_tag 'scaffold', 'depot' %> diff --git a/app/views/products/edit.html.erb b/app/views/products/edit.html.erb index af3b747..7aa095b 100644 --- a/app/views/products/edit.html.erb +++ b/app/views/products/edit.html.erb @@ -15,6 +15,10 @@ <%= f.label :image_url %>
<%= f.text_field :image_url %>

+

+ <%= f.label :price %>
+ <%= f.text_field :price %> +

<%= f.submit "Update" %>

diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb index 88120ee..1db53b8 100644 --- a/app/views/products/index.html.erb +++ b/app/views/products/index.html.erb @@ -1,24 +1,34 @@ -

Listing products

+
+

Listing products

- - - - - - +
TitleDescriptionImage url
+ <% for product in @products %> + -<% for product in @products %> - - - - - - - - -<% end %> -
<%=h product.title %><%=h product.description %><%=h product.image_url %><%= link_to 'Show', product %><%= link_to 'Edit', edit_product_path(product) %><%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %>
+ + <%= image_tag product.image_url, :class => 'list-image' %> + -
+ +
+
<%= h product.title %>
+
<%= h truncate(product.description.gsub(/<.*?>/, ''), + :length => 80) %>
+
+ + + + <%= link_to 'Show', product %>
+ <%= link_to 'Edit', edit_product_path(product) %>
+ <%= link_to 'Destroy', product, + :confirm => 'Are you sure?', + :method => :delete %> + + + <% end %> + +
+ +
<%= link_to 'New product', new_product_path %> diff --git a/app/views/products/new.html.erb b/app/views/products/new.html.erb index f935937..90ef7f2 100644 --- a/app/views/products/new.html.erb +++ b/app/views/products/new.html.erb @@ -15,7 +15,11 @@ <%= f.label :image_url %>
<%= f.text_field :image_url %>

-

+

+ <%= f.label :price %>
+ <%= f.text_field :price %> +

+

<%= f.submit "Create" %>

<% end %> diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index a5f0eac..124ab77 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -13,6 +13,11 @@ <%=h @product.image_url %>

+

+ Price: + <%=h @product.price %> +

+ <%= link_to 'Edit', edit_product_path(@product) %> | <%= link_to 'Back', products_path %> diff --git a/config/environment.rb b/config/environment.rb index 73cc3e4..bedc82c 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -5,7 +5,8 @@ # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present -RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION +# RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION +RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') diff --git a/db/migrate/20090128142730_add_product_price.rb b/db/migrate/20090128142730_add_product_price.rb new file mode 100644 index 0000000..f49426b --- /dev/null +++ b/db/migrate/20090128142730_add_product_price.rb @@ -0,0 +1,9 @@ +class AddProductPrice < 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 diff --git a/db/migrate/20090130111521_add_test_data.rb b/db/migrate/20090130111521_add_test_data.rb new file mode 100644 index 0000000..975146e --- /dev/null +++ b/db/migrate/20090130111521_add_test_data.rb @@ -0,0 +1,56 @@ +class AddTestData < ActiveRecord::Migration + def self.up + Product.delete_all + Product.create(:title => 'Pragmatic Project Automation', + :description => + %{

+ 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. +

}, + :image_url => '/images/auto.jpg', + :price => 29.95) + + Product.create(: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. don't use + any version control at all. Many others don't use it well, and end + up experiencing time-consuming problems. +

}, + :image_url => '/images/svn.jpg', + :price => 28.50) + + Product.create(:title => 'Pragmatic Unit Testing (C#)', + :description => + %{

+ 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. +

}, + :image_url => '/images/utc.jpg', + :price => 27.75) + + end + + def self.down + Product.delete_all + end +end diff --git a/db/schema.rb b/db/schema.rb index c702c8e..b873092 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20080724075409) do +ActiveRecord::Schema.define(:version => 20090130111521) do create_table "products", :force => true do |t| t.string "title" @@ -17,6 +17,7 @@ ActiveRecord::Schema.define(:version => 20080724075409) do t.string "image_url" t.datetime "created_at" t.datetime "updated_at" + t.decimal "price", :precision => 8, :scale => 2, :default => 0.0 end end diff --git a/log/development.log b/log/development.log index 0057ea8..95b56a7 100644 --- a/log/development.log +++ b/log/development.log @@ -141,3 +141,443 @@ Rendering template within layouts/products Rendering products/index Product Columns (0.003374) SHOW FIELDS FROM `products` Completed in 0.02020 (49 reqs/sec) | Rendering: 0.00515 (25%) | DB: 0.00370 (18%) | 200 OK [http://localhost/products] + SQL (0.3ms) SET SQL_AUTO_IS_NULL=0 + SQL (17.9ms) SHOW TABLES + SQL (0.2ms) SELECT version FROM schema_migrations +Migrating to CreateProducts (20080724075409) +Migrating to AddProductPrice (20090128142730) + SQL (222.8ms) ALTER TABLE `products` ADD `price` decimal(8,2) DEFAULT 2 + SQL (0.8ms) INSERT INTO schema_migrations (version) VALUES ('20090128142730') + SQL (0.6ms) SHOW TABLES + SQL (0.4ms) SELECT version FROM schema_migrations + SQL (0.5ms) SHOW TABLES + SQL (2.2ms) SHOW FIELDS FROM `products` + SQL (1.9ms) describe `products` + SQL (1.0ms) SHOW KEYS FROM `products` + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + SQL (0.5ms) SHOW TABLES + SQL (0.2ms) SELECT version FROM schema_migrations + SQL (0.4ms) SHOW TABLES + SQL (0.2ms) SELECT version FROM schema_migrations +Migrating to AddProductPrice (20090128142730) + SQL (27.2ms) ALTER TABLE `products` DROP `price` + SQL (40.9ms) DELETE FROM schema_migrations WHERE version = '20090128142730' +Migrating to CreateProducts (20080724075409) + SQL (26.4ms) DROP TABLE `products` + SQL (38.8ms) DELETE FROM schema_migrations WHERE version = '20080724075409' + SQL (0.5ms) SHOW TABLES + SQL (0.4ms) SELECT version FROM schema_migrations + SQL (0.4ms) SHOW TABLES + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + SQL (0.4ms) SHOW TABLES + SQL (0.2ms) SELECT version FROM schema_migrations +Migrating to CreateProducts (20080724075409) + SQL (30.6ms) CREATE TABLE `products` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `title` varchar(255), `description` text, `image_url` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB + SQL (25.8ms) INSERT INTO schema_migrations (version) VALUES ('20080724075409') +Migrating to AddProductPrice (20090128142730) + SQL (16.2ms) ALTER TABLE `products` ADD `price` decimal(8,2) DEFAULT 0 + SQL (0.8ms) INSERT INTO schema_migrations (version) VALUES ('20090128142730') + SQL (0.5ms) SHOW TABLES + SQL (0.4ms) SELECT version FROM schema_migrations + SQL (0.5ms) SHOW TABLES + SQL (3.6ms) SHOW FIELDS FROM `products` + SQL (1.9ms) describe `products` + SQL (0.6ms) SHOW KEYS FROM `products` + + +Processing ProductsController#index (for 127.0.0.1 at 2009-01-30 10:55:37) [GET] + SQL (41.3ms) SET SQL_AUTO_IS_NULL=0 + Product Load (49.7ms) SELECT * FROM `products`  +Rendering template within layouts/products +Rendering products/index + Product Columns (23.1ms) SHOW FIELDS FROM `products` +Completed in 234ms (View: 147, DB: 114) | 200 OK [http://localhost/products] + + +Processing ProductsController#edit (for 127.0.0.1 at 2009-01-30 10:55:41) [GET] + Parameters: {"id"=>"1"} + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Columns (1.1ms) SHOW FIELDS FROM `products` + Product Load (23.3ms) SELECT * FROM `products` WHERE (`products`.`id` = 1)  +Rendering template within layouts/products +Rendering products/edit +Completed in 52ms (View: 16, DB: 24) | 200 OK [http://localhost/products/1/edit] + + +Processing ProductsController#update (for 127.0.0.1 at 2009-01-30 10:55:42) [PUT] + Parameters: {"commit"=>"Update", "authenticity_token"=>"f081ce86efd30d00f8269cdde39c0b562c696c34", "product"=>{"image_url"=>"", "price"=>"17.00", "title"=>"First product", "description"=>"This is the description of the first product"}, "id"=>"1"} + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Columns (1.2ms) SHOW FIELDS FROM `products` + Product Load (0.3ms) SELECT * FROM `products` WHERE (`products`.`id` = 1)  + SQL (0.7ms) BEGIN + Product Exists (62.9ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'First product' AND `products`.id <> 1) LIMIT 1 + SQL (0.2ms) ROLLBACK +Rendering template within layouts/products +Rendering products/edit +Completed in 182ms (View: 22, DB: 65) | 200 OK [http://localhost/products/1] + + +Processing ProductsController#update (for 127.0.0.1 at 2009-01-30 10:56:00) [PUT] + Parameters: {"commit"=>"Update", "authenticity_token"=>"f081ce86efd30d00f8269cdde39c0b562c696c34", "product"=>{"image_url"=>"prod1", "price"=>"17.00", "title"=>"First product", "description"=>"This is the description of the first product"}, "id"=>"1"} + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Columns (1.3ms) SHOW FIELDS FROM `products` + Product Load (0.1ms) SELECT * FROM `products` WHERE (`products`.`id` = 1)  + SQL (0.1ms) BEGIN + Product Exists (0.1ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'First product' AND `products`.id <> 1) LIMIT 1 + SQL (0.2ms) ROLLBACK +Rendering template within layouts/products +Rendering products/edit +Completed in 42ms (View: 16, DB: 2) | 200 OK [http://localhost/products/1] + + +Processing ProductsController#update (for 127.0.0.1 at 2009-01-30 10:56:04) [PUT] + Parameters: {"commit"=>"Update", "authenticity_token"=>"f081ce86efd30d00f8269cdde39c0b562c696c34", "product"=>{"image_url"=>"prod1.png", "price"=>"17.00", "title"=>"First product", "description"=>"This is the description of the first product"}, "id"=>"1"} + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + Product Columns (1.1ms) SHOW FIELDS FROM `products` + Product Load (0.2ms) SELECT * FROM `products` WHERE (`products`.`id` = 1)  + SQL (0.1ms) BEGIN + Product Exists (0.1ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'First product' AND `products`.id <> 1) LIMIT 1 + Product Update (31.3ms) UPDATE `products` SET `updated_at` = '2009-01-30 10:56:04', `image_url` = 'prod1.png' WHERE `id` = 1 + SQL (8.9ms) COMMIT +Redirected to # +Completed in 69ms (DB: 42) | 302 Found [http://localhost/products/1] + + +Processing ProductsController#show (for 127.0.0.1 at 2009-01-30 10:56:04) [GET] + Parameters: {"id"=>"1"} + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + Product Columns (2.4ms) SHOW FIELDS FROM `products` + Product Load (0.6ms) SELECT * FROM `products` WHERE (`products`.`id` = 1)  +Rendering template within layouts/products +Rendering products/show +Completed in 43ms (View: 17, DB: 3) | 200 OK [http://localhost/products/1] + + +Processing ProductsController#index (for 127.0.0.1 at 2009-01-30 10:56:07) [GET] + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Load (0.4ms) SELECT * FROM `products`  +Rendering template within layouts/products +Rendering products/index + Product Columns (1.7ms) SHOW FIELDS FROM `products` +Completed in 28ms (View: 14, DB: 2) | 200 OK [http://localhost/products] + + +Processing ProductsController#new (for 127.0.0.1 at 2009-01-30 10:56:13) [GET] + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Columns (1.1ms) SHOW FIELDS FROM `products` +Rendering template within layouts/products +Rendering products/new +Completed in 34ms (View: 21, DB: 1) | 200 OK [http://localhost/products/new] + + +Processing ProductsController#create (for 127.0.0.1 at 2009-01-30 10:56:15) [POST] + Parameters: {"commit"=>"Create", "authenticity_token"=>"f081ce86efd30d00f8269cdde39c0b562c696c34", "product"=>{"image_url"=>"", "price"=>"0.0", "title"=>"", "description"=>""}} + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Columns (1.2ms) SHOW FIELDS FROM `products` + SQL (0.1ms) BEGIN + Product Exists (0.4ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY '') LIMIT 1 + SQL (0.2ms) ROLLBACK +Rendering template within layouts/products +Rendering products/new +Completed in 49ms (View: 18, DB: 2) | 200 OK [http://localhost/products] + + +Processing ProductsController#index (for 127.0.0.1 at 2009-01-30 10:56:26) [GET] + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Load (0.2ms) SELECT * FROM `products`  +Rendering template within layouts/products +Rendering products/index + Product Columns (1.4ms) SHOW FIELDS FROM `products` +Completed in 32ms (View: 16, DB: 2) | 200 OK [http://localhost/products] + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + SQL (0.4ms) SHOW TABLES + SQL (0.4ms) SELECT version FROM schema_migrations +Migrating to CreateProducts (20080724075409) +Migrating to AddProductPrice (20090128142730) +Migrating to AddTestData (20090130111521) + Product Delete all (8.2ms) DELETE FROM `products`  + Product Columns (1.7ms) SHOW FIELDS FROM `products` + SQL (0.1ms) BEGIN + Product Exists (0.4ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'Pragmatic Version Control') LIMIT 1 + Product Create (28.2ms) INSERT INTO `products` (`image_url`, `updated_at`, `title`, `price`, `description`, `created_at`) VALUES('/images/auto.jpg', '2009-01-30 11:21:28', 'Pragmatic Version Control', 29.95, '

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

\n

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

', '2009-01-30 11:21:28') + SQL (0.6ms) COMMIT + SQL (0.1ms) BEGIN + Product Exists (0.4ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'Pragmatic Version Control') LIMIT 1 + SQL (0.1ms) ROLLBACK + SQL (0.1ms) BEGIN + Product Exists (0.4ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'Pragmatic Unit Testing (C#)') LIMIT 1 + Product Create (0.4ms) INSERT INTO `products` (`image_url`, `updated_at`, `title`, `price`, `description`, `created_at`) VALUES('/images/utc.jpg', '2009-01-30 11:21:28', 'Pragmatic Unit Testing (C#)', 27.75, '

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

\n

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

', '2009-01-30 11:21:28') + SQL (0.5ms) COMMIT + SQL (23.8ms) INSERT INTO schema_migrations (version) VALUES ('20090130111521') + SQL (0.4ms) SHOW TABLES + SQL (0.3ms) SELECT version FROM schema_migrations + SQL (0.3ms) SHOW TABLES + SQL (1.0ms) SHOW FIELDS FROM `products` + SQL (1.1ms) describe `products` + SQL (0.5ms) SHOW KEYS FROM `products` + + +Processing ProductsController#index (for 127.0.0.1 at 2009-01-30 11:21:36) [GET] + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Load (0.7ms) SELECT * FROM `products`  +Rendering template within layouts/products +Rendering products/index + Product Columns (1.1ms) SHOW FIELDS FROM `products` +Completed in 34ms (View: 19, DB: 2) | 200 OK [http://localhost/products] + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + SQL (0.4ms) SHOW TABLES + SQL (0.2ms) SELECT version FROM schema_migrations + SQL (0.3ms) SHOW TABLES + SQL (0.2ms) SELECT version FROM schema_migrations +Migrating to AddTestData (20090130111521) + Product Delete all (7.2ms) DELETE FROM `products`  + SQL (9.5ms) DELETE FROM schema_migrations WHERE version = '20090130111521' +Migrating to AddProductPrice (20090128142730) + SQL (174.7ms) ALTER TABLE `products` DROP `price` + SQL (0.7ms) DELETE FROM schema_migrations WHERE version = '20090128142730' +Migrating to CreateProducts (20080724075409) + SQL (1.4ms) DROP TABLE `products` + SQL (0.7ms) DELETE FROM schema_migrations WHERE version = '20080724075409' + SQL (0.4ms) SHOW TABLES + SQL (0.4ms) SELECT version FROM schema_migrations + SQL (0.5ms) SHOW TABLES + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + SQL (0.5ms) SHOW TABLES + SQL (0.2ms) SELECT version FROM schema_migrations +Migrating to CreateProducts (20080724075409) + SQL (6.1ms) CREATE TABLE `products` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `title` varchar(255), `description` text, `image_url` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB + SQL (0.8ms) INSERT INTO schema_migrations (version) VALUES ('20080724075409') +Migrating to AddProductPrice (20090128142730) + SQL (8.7ms) ALTER TABLE `products` ADD `price` decimal(8,2) DEFAULT 0 + SQL (0.8ms) INSERT INTO schema_migrations (version) VALUES ('20090128142730') +Migrating to AddTestData (20090130111521) + Product Delete all (9.7ms) DELETE FROM `products`  + Product Columns (2.1ms) SHOW FIELDS FROM `products` + SQL (0.2ms) BEGIN + Product Exists (0.5ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'Pragmatic Project Automation') LIMIT 1 + Product Create (0.4ms) INSERT INTO `products` (`image_url`, `updated_at`, `title`, `price`, `description`, `created_at`) VALUES('/images/auto.jpg', '2009-01-30 11:22:38', 'Pragmatic Project Automation', 29.95, '

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

\n

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

', '2009-01-30 11:22:38') + SQL (0.6ms) COMMIT + SQL (0.2ms) BEGIN + Product Exists (0.4ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'Pragmatic Version Control') LIMIT 1 + Product Create (0.4ms) INSERT INTO `products` (`image_url`, `updated_at`, `title`, `price`, `description`, `created_at`) VALUES('/images/svn.jpg', '2009-01-30 11:22:38', 'Pragmatic Version Control', 28.5, '

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

', '2009-01-30 11:22:38') + SQL (0.6ms) COMMIT + SQL (0.2ms) BEGIN + Product Exists (0.4ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'Pragmatic Unit Testing (C#)') LIMIT 1 + Product Create (0.5ms) INSERT INTO `products` (`image_url`, `updated_at`, `title`, `price`, `description`, `created_at`) VALUES('/images/utc.jpg', '2009-01-30 11:22:38', 'Pragmatic Unit Testing (C#)', 27.75, '

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

\n

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

', '2009-01-30 11:22:38') + SQL (6.3ms) COMMIT + SQL (13.7ms) INSERT INTO schema_migrations (version) VALUES ('20090130111521') + SQL (0.5ms) SHOW TABLES + SQL (0.4ms) SELECT version FROM schema_migrations + SQL (0.5ms) SHOW TABLES + SQL (1.8ms) SHOW FIELDS FROM `products` + SQL (1.8ms) describe `products` + SQL (0.7ms) SHOW KEYS FROM `products` + + +Processing ProductsController#index (for 127.0.0.1 at 2009-01-30 11:22:43) [GET] + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + Product Load (0.4ms) SELECT * FROM `products`  +Rendering template within layouts/products +Rendering products/index + Product Columns (1.1ms) SHOW FIELDS FROM `products` +Completed in 31ms (View: 17, DB: 2) | 200 OK [http://localhost/products] + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + SQL (0.4ms) SHOW TABLES + SQL (0.1ms) SELECT version FROM schema_migrations + SQL (0.3ms) SHOW TABLES + SQL (0.2ms) SELECT version FROM schema_migrations +Migrating to AddTestData (20090130111521) + Product Delete all (5.1ms) DELETE FROM `products`  + SQL (12.1ms) DELETE FROM schema_migrations WHERE version = '20090130111521' +Migrating to AddProductPrice (20090128142730) + SQL (30.2ms) ALTER TABLE `products` DROP `price` + SQL (0.7ms) DELETE FROM schema_migrations WHERE version = '20090128142730' +Migrating to CreateProducts (20080724075409) + SQL (2.0ms) DROP TABLE `products` + SQL (6.3ms) DELETE FROM schema_migrations WHERE version = '20080724075409' + SQL (0.4ms) SHOW TABLES + SQL (0.4ms) SELECT version FROM schema_migrations + SQL (0.4ms) SHOW TABLES + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + SQL (1.2ms) SHOW TABLES + SQL (0.2ms) SELECT version FROM schema_migrations +Migrating to CreateProducts (20080724075409) + SQL (3.4ms) CREATE TABLE `products` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `title` varchar(255), `description` text, `image_url` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB + SQL (0.8ms) INSERT INTO schema_migrations (version) VALUES ('20080724075409') +Migrating to AddProductPrice (20090128142730) + SQL (6.6ms) ALTER TABLE `products` ADD `price` decimal(8,2) DEFAULT 0 + SQL (0.7ms) INSERT INTO schema_migrations (version) VALUES ('20090128142730') +Migrating to AddTestData (20090130111521) + Product Delete all (0.4ms) DELETE FROM `products`  + Product Columns (1.1ms) SHOW FIELDS FROM `products` + SQL (0.1ms) BEGIN + Product Exists (0.6ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'Pragmatic Project Automation') LIMIT 1 + Product Create (0.6ms) INSERT INTO `products` (`image_url`, `updated_at`, `title`, `price`, `description`, `created_at`) VALUES('/images/auto.jpg', '2009-01-30 11:26:48', 'Pragmatic Project Automation', 29.95, '

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

\n

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

', '2009-01-30 11:26:48') + SQL (0.7ms) COMMIT + SQL (0.1ms) BEGIN + Product Exists (0.4ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'Pragmatic Version Control') LIMIT 1 + Product Create (1.0ms) INSERT INTO `products` (`image_url`, `updated_at`, `title`, `price`, `description`, `created_at`) VALUES('/images/svn.jpg', '2009-01-30 11:26:48', 'Pragmatic Version Control', 28.5, '

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

', '2009-01-30 11:26:48') + SQL (1.8ms) COMMIT + SQL (0.1ms) BEGIN + Product Exists (0.4ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'Pragmatic Unit Testing (C#)') LIMIT 1 + Product Create (0.4ms) INSERT INTO `products` (`image_url`, `updated_at`, `title`, `price`, `description`, `created_at`) VALUES('/images/utc.jpg', '2009-01-30 11:26:48', 'Pragmatic Unit Testing (C#)', 27.75, '

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

\n

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

', '2009-01-30 11:26:48') + SQL (2.0ms) COMMIT + SQL (8.2ms) INSERT INTO schema_migrations (version) VALUES ('20090130111521') + SQL (0.4ms) SHOW TABLES + SQL (0.3ms) SELECT version FROM schema_migrations + SQL (0.3ms) SHOW TABLES + SQL (1.0ms) SHOW FIELDS FROM `products` + SQL (1.0ms) describe `products` + SQL (0.4ms) SHOW KEYS FROM `products` + + +Processing ProductsController#index (for 127.0.0.1 at 2009-01-30 11:26:52) [GET] + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Load (0.4ms) SELECT * FROM `products`  +Rendering template within layouts/products +Rendering products/index + Product Columns (1.1ms) SHOW FIELDS FROM `products` +Completed in 37ms (View: 24, DB: 2) | 200 OK [http://localhost/products] + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + SQL (0.4ms) SHOW TABLES + SQL (0.1ms) SELECT version FROM schema_migrations + SQL (0.5ms) SHOW TABLES + SQL (0.1ms) SELECT version FROM schema_migrations +Migrating to AddTestData (20090130111521) + Product Delete all (12.5ms) DELETE FROM `products`  + SQL (12.4ms) DELETE FROM schema_migrations WHERE version = '20090130111521' +Migrating to AddProductPrice (20090128142730) + SQL (22.2ms) ALTER TABLE `products` DROP `price` + SQL (0.7ms) DELETE FROM schema_migrations WHERE version = '20090128142730' +Migrating to CreateProducts (20080724075409) + SQL (6.1ms) DROP TABLE `products` + SQL (0.9ms) DELETE FROM schema_migrations WHERE version = '20080724075409' + SQL (0.4ms) SHOW TABLES + SQL (0.3ms) SELECT version FROM schema_migrations + SQL (0.4ms) SHOW TABLES + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + SQL (0.4ms) SHOW TABLES + SQL (0.1ms) SELECT version FROM schema_migrations +Migrating to CreateProducts (20080724075409) + SQL (4.6ms) CREATE TABLE `products` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `title` varchar(255), `description` text, `image_url` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB + SQL (0.7ms) INSERT INTO schema_migrations (version) VALUES ('20080724075409') +Migrating to AddProductPrice (20090128142730) + SQL (7.3ms) ALTER TABLE `products` ADD `price` decimal(8,2) DEFAULT 0 + SQL (0.8ms) INSERT INTO schema_migrations (version) VALUES ('20090128142730') +Migrating to AddTestData (20090130111521) + Product Delete all (1.1ms) DELETE FROM `products`  + Product Columns (2.5ms) SHOW FIELDS FROM `products` + SQL (0.2ms) BEGIN + Product Exists (0.5ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'Pragmatic Project Automation') LIMIT 1 + Product Create (0.4ms) INSERT INTO `products` (`image_url`, `updated_at`, `title`, `price`, `description`, `created_at`) VALUES('/images/auto.jpg', '2009-01-30 11:28:11', 'Pragmatic Project Automation', 29.95, '

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

\n

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

', '2009-01-30 11:28:11') + SQL (0.5ms) COMMIT + SQL (0.1ms) BEGIN + Product Exists (0.4ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'Pragmatic Version Control') LIMIT 1 + Product Create (0.3ms) INSERT INTO `products` (`image_url`, `updated_at`, `title`, `price`, `description`, `created_at`) VALUES('/images/svn.jpg', '2009-01-30 11:28:11', 'Pragmatic Version Control', 28.5, '

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

', '2009-01-30 11:28:11') + SQL (0.5ms) COMMIT + SQL (0.2ms) BEGIN + Product Exists (0.6ms) SELECT `products`.id FROM `products` WHERE (`products`.`title` = BINARY 'Pragmatic Unit Testing (C#)') LIMIT 1 + Product Create (0.3ms) INSERT INTO `products` (`image_url`, `updated_at`, `title`, `price`, `description`, `created_at`) VALUES('/images/utc.jpg', '2009-01-30 11:28:11', 'Pragmatic Unit Testing (C#)', 27.75, '

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

\n

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

', '2009-01-30 11:28:11') + SQL (1.3ms) COMMIT + SQL (0.7ms) INSERT INTO schema_migrations (version) VALUES ('20090130111521') + SQL (0.9ms) SHOW TABLES + SQL (0.4ms) SELECT version FROM schema_migrations + SQL (0.3ms) SHOW TABLES + SQL (1.0ms) SHOW FIELDS FROM `products` + SQL (1.3ms) describe `products` + SQL (0.4ms) SHOW KEYS FROM `products` + + +Processing ProductsController#index (for 127.0.0.1 at 2009-01-30 11:28:19) [GET] + SQL (0.3ms) SET SQL_AUTO_IS_NULL=0 + Product Load (1.3ms) SELECT * FROM `products`  +Rendering template within layouts/products +Rendering products/index + Product Columns (1.2ms) SHOW FIELDS FROM `products` +Completed in 30ms (View: 15, DB: 3) | 200 OK [http://localhost/products] + + +Processing ProductsController#index (for 127.0.0.1 at 2009-01-30 11:53:52) [GET] + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + Product Load (0.3ms) SELECT * FROM `products`  +Rendering template within layouts/products +Rendering products/index + Product Columns (1.3ms) SHOW FIELDS FROM `products` +Completed in 41ms (View: 24, DB: 2) | 200 OK [http://localhost/products] + + +Processing ProductsController#show (for 127.0.0.1 at 2009-01-30 11:53:55) [GET] + Parameters: {"id"=>"1"} + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + Product Columns (2.1ms) SHOW FIELDS FROM `products` + Product Load (0.7ms) SELECT * FROM `products` WHERE (`products`.`id` = 1)  +Rendering template within layouts/products +Rendering products/show +Completed in 41ms (View: 20, DB: 3) | 200 OK [http://localhost/products/1] + + +Processing ProductsController#show (for 127.0.0.1 at 2009-01-30 11:54:35) [GET] + Parameters: {"id"=>"3"} + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Columns (1.3ms) SHOW FIELDS FROM `products` + Product Load (0.4ms) SELECT * FROM `products` WHERE (`products`.`id` = 3)  +Rendering template within layouts/products +Rendering products/show +Completed in 29ms (View: 14, DB: 2) | 200 OK [http://localhost/products/3] + + +Processing ProductsController#index (for 127.0.0.1 at 2009-01-30 11:54:44) [GET] + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Load (0.3ms) SELECT * FROM `products`  +Rendering template within layouts/products +Rendering products/index + Product Columns (1.2ms) SHOW FIELDS FROM `products` +Completed in 39ms (View: 24, DB: 2) | 200 OK [http://localhost/products] + + +Processing ProductsController#show (for 127.0.0.1 at 2009-01-30 11:55:35) [GET] + Parameters: {"id"=>"3"} + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Columns (1.1ms) SHOW FIELDS FROM `products` + Product Load (0.1ms) SELECT * FROM `products` WHERE (`products`.`id` = 3)  +Rendering template within layouts/products +Rendering products/show +Completed in 27ms (View: 13, DB: 1) | 200 OK [http://localhost/products/3] + + +Processing ProductsController#edit (for 127.0.0.1 at 2009-01-30 11:55:43) [GET] + Parameters: {"id"=>"2"} + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Columns (1.9ms) SHOW FIELDS FROM `products` + Product Load (0.5ms) SELECT * FROM `products` WHERE (`products`.`id` = 2)  +Rendering template within layouts/products +Rendering products/edit +Completed in 33ms (View: 18, DB: 2) | 200 OK [http://localhost/products/2/edit] + + +Processing ProductsController#index (for 127.0.0.1 at 2009-01-30 11:56:05) [GET] + SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 + Product Load (0.2ms) SELECT * FROM `products`  +Rendering template within layouts/products +Rendering products/index + Product Columns (1.1ms) SHOW FIELDS FROM `products` +Completed in 35ms (View: 20, DB: 1) | 200 OK [http://localhost/products] + + +Processing ProductsController#show (for 127.0.0.1 at 2009-01-30 11:56:08) [GET] + Parameters: {"id"=>"2"} + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Columns (1.1ms) SHOW FIELDS FROM `products` + Product Load (0.2ms) SELECT * FROM `products` WHERE (`products`.`id` = 2)  +Rendering template within layouts/products +Rendering products/show +Completed in 26ms (View: 12, DB: 1) | 200 OK [http://localhost/products/2] + + +Processing ProductsController#index (for 127.0.0.1 at 2009-01-30 11:56:25) [GET] + SQL (0.1ms) SET SQL_AUTO_IS_NULL=0 + Product Load (0.2ms) SELECT * FROM `products`  +Rendering template within layouts/products +Rendering products/index + Product Columns (1.9ms) SHOW FIELDS FROM `products` +Completed in 35ms (View: 21, DB: 2) | 200 OK [http://localhost/products] diff --git a/public/stylesheets/depot.css b/public/stylesheets/depot.css new file mode 100644 index 0000000..bb9c8b5 --- /dev/null +++ b/public/stylesheets/depot.css @@ -0,0 +1,141 @@ +/* Global styles */ + +h1 { + font: 150% sans-serif; + color: #226; + border-bottom: 3px dotted #77d; +} + +/* Styles for products/index */ + +#product-list table { + border-collapse: collapse; +} + +#product-list table tr td { + padding: 5px; + vertical-align: top; +} + +#product-list .list-image { + width: 60px; + height: 70px; +} + +#product-list .list-description { + width: 60%; +} + +#product-list .list-description dl { + margin: 0; +} + +#product-list .list-description dt { + color: #244; + font-weight: bold; + font-size: larger; +} + +#product-list .list-description dd { + margin: 0; +} + +#product-list .list-actions { + font-size: x-small; + text-align: right; + padding-left: 1em; +} + +#product-list .list-line-even { + background: #e0f8f8; +} + +#product-list .list-line-odd { + background: #f8b0f8; +} + +/* An entry in the store catalog */ + +#store .entry { + overflow: auto; + margin-top: 1em; + border-bottom: 1px dotted #77d; +} + +#store .title { + font-size: 120%; + font-family: sans-serif; +} + +#store .entry img { + width: 75px; + float: left; +} + + +#store .entry h3 { + margin-top: 0; + margin-bottom: 2px; + color: #227; +} + +#store .entry p { + margin-top: 0.5em; + margin-bottom: 0.8em; +} + +#store .entry .price-line { + clear: both; +} + +#store .entry .add-to-cart { + position: relative; +} + +#store .entry .price { + color: #44a; + font-weight: bold; + margin-right: 2em; +} + +/* The error box */ + +.fieldWithErrors { + padding: 2px; + background-color: #EEFFEE; + display: inline; +} + +.fieldWithErrors * { + background-color: red; +} + +#errorExplanation { + width: 400px; + border: 2px solid red; + padding: 7px; + padding-bottom: 12px; + margin-bottom: 20px; + background-color: #f0f0f0; +} + +#errorExplanation h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + background-color: #c00; + color: #fff; +} + +#errorExplanation p { + color: #333; + margin-bottom: 0; + padding: 5px; +} + +#errorExplanation ul li { + font-size: 12px; + list-style: square; +}