From 3b424e341e1dda1f67b4461de089b76eb69bbc70 Mon Sep 17 00:00:00 2001
From: Neil Smith
<%= f.text_field :price %>
+ <%= f.label :date_available %>
+ <%= f.date_select :date_available, :order => [:day, :month, :year] %>
+
<%= f.submit "Update" %>
diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb index 1db53b8..6bb547a 100644 --- a/app/views/products/index.html.erb +++ b/app/views/products/index.html.erb @@ -14,6 +14,11 @@+
+ <%= f.label :date_available %>
+ <%= f.date_select :date_available, :order => [:day, :month, :year] %>
+
<%= f.submit "Create" %>
<% end %> diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index 124ab77..fb3631e 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -18,6 +18,11 @@ <%=h @product.price %> ++ Date available: + <%=h @product.date_available %> +
+ <%= link_to 'Edit', edit_product_path(@product) %> | <%= link_to 'Back', products_path %> diff --git a/db/migrate/20090202124100_add_product_date_available.rb b/db/migrate/20090202124100_add_product_date_available.rb new file mode 100644 index 0000000..4c05607 --- /dev/null +++ b/db/migrate/20090202124100_add_product_date_available.rb @@ -0,0 +1,13 @@ +class AddProductDateAvailable < ActiveRecord::Migration + def self.up + add_column :products, :date_available, :date + + Product.update(1, :date_available => Time.utc(2008, 12, 25)) + Product.update(2, :date_available => Time.utc(2010, 12, 25)) + Product.update(3, :date_available => Time.utc(2009, 1, 1)) + end + + def self.down + remove_column :products, :date_available + end +end diff --git a/db/schema.rb b/db/schema.rb index b873092..2b20ee9 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 => 20090130111521) do +ActiveRecord::Schema.define(:version => 20090202124100) do create_table "products", :force => true do |t| t.string "title" @@ -17,7 +17,8 @@ ActiveRecord::Schema.define(:version => 20090130111521) do t.string "image_url" t.datetime "created_at" t.datetime "updated_at" - t.decimal "price", :precision => 8, :scale => 2, :default => 0.0 + t.decimal "price", :precision => 8, :scale => 2, :default => 0.0 + t.date "date_available" end end diff --git a/public/stylesheets/depot.css b/public/stylesheets/depot.css index bb9c8b5..62a2d67 100644 --- a/public/stylesheets/depot.css +++ b/public/stylesheets/depot.css @@ -40,6 +40,10 @@ h1 { margin: 0; } +#product-list .list-description .unavailable { + color: #f00; +} + #product-list .list-actions { font-size: x-small; text-align: right; -- 2.34.1