From c445da2b4dc5097fcfddf5e40d74c2965573fc1c Mon Sep 17 00:00:00 2001
From: Neil Smith
<%= f.date_select :date_available, :order => [:day, :month, :year] %>
+ <%= f.label :date_available_until %>
+ <%= f.date_select :date_available_until, :order => [:day, :month, :year], :include_blank => true %>
+
<%= f.submit "Update" %>
diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb index 3e068e6..1bed039 100644 --- a/app/views/products/index.html.erb +++ b/app/views/products/index.html.erb @@ -18,6 +18,13 @@ <% else %>
+ <%= f.label :date_available_until %>
+ <%= f.date_select :date_available_until, :order => [:day, :month, :year], :include_blank => true %>
+
<%= f.submit "Create" %>
diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index fb3631e..5fc752f 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -23,6 +23,10 @@ <%=h @product.date_available %> ++ Available until: + <%=h @product.date_available_until %> +
<%= link_to 'Edit', edit_product_path(@product) %> | <%= link_to 'Back', products_path %> diff --git a/db/migrate/20090202163608_add_test_data.rb b/db/migrate/20090202163608_add_test_data.rb index 35a0a7a..0bf4e82 100644 --- a/db/migrate/20090202163608_add_test_data.rb +++ b/db/migrate/20090202163608_add_test_data.rb @@ -29,7 +29,7 @@ class AddTestData < ActiveRecord::Migration }, :image_url => '/images/daisy.gif', - :price => 5.00, + :price => 4.99, :date_available => Time.utc(2011, 7, 1) ) @@ -57,7 +57,7 @@ class AddTestData < ActiveRecord::Migration }, :image_url => '/images/can-of-air.jpg', - :price => 5000.00, + :price => 4999.95, :date_available => Time.utc(2009, 1, 1) ) end diff --git a/db/migrate/20090226212213_add_date_avilable_until_to_product.rb b/db/migrate/20090226212213_add_date_avilable_until_to_product.rb new file mode 100644 index 0000000..bfc90e5 --- /dev/null +++ b/db/migrate/20090226212213_add_date_avilable_until_to_product.rb @@ -0,0 +1,10 @@ +class AddDateAvilableUntilToProduct < ActiveRecord::Migration + def self.up + add_column :products, :date_available_until, :date + Product.reset_column_information + end + + def self.down + remove_column :products, :date_available_until + end +end diff --git a/db/migrate/20090226212307_add_more_test_data.rb b/db/migrate/20090226212307_add_more_test_data.rb new file mode 100644 index 0000000..d91721b --- /dev/null +++ b/db/migrate/20090226212307_add_more_test_data.rb @@ -0,0 +1,31 @@ +class AddMoreTestData < ActiveRecord::Migration + def self.up + Product.create(:title => 'Rainbow', + :description => + %{What could be better than a beautiful rainbow to brighten up your + day? Experience the wonder of light and water in all its glory. +
+Due to metreological variations, the rainbow you receive may + differ slightly from the one shown here. +
+(Terminal gold not included.) +
+ }, + :image_url => '/images/rainbow.jpg', + :price => 17.99, + :date_available => Time.utc(2008, 12, 31), + :date_available_until => Time.utc(2009, 1, 1) +# :available_until => 'fred' +# :au => Time.utc(2008, 12, 31) + ) + + box = Product.find(3) + box.update_attribute(:date_available_until, Time.utc(2010, 7, 1)) +# box.update_attribute(:available_until, 'tom') +# box.update_attribute(:au, Time.utc(2010, 7, 1)) + end + + def self.down + Product.delete_all(["title = ?", 'Rainbow']) + end +end diff --git a/db/schema.rb b/db/schema.rb index dc43da5..d08e763 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 => 20090202163608) do +ActiveRecord::Schema.define(:version => 20090226212307) do create_table "products", :force => true do |t| t.string "title" @@ -17,8 +17,19 @@ ActiveRecord::Schema.define(:version => 20090202163608) 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" + t.date "date_available_until" end + create_table "sessions", :force => true do |t| + t.string "session_id", :null => false + t.text "data" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" + add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" + end -- 2.34.1