<%= f.label :price %><br />
<%= f.text_field :price %>
</p>
+ <p>
+ <%= f.label :date_available %><br />
+ <%= f.date_select :date_available, :order => [:day, :month, :year] %>
+ </p>
<p>
<%= f.submit "Update" %>
</p>
<dt><%= h product.title %></dt>
<dd><%= h truncate(product.description.gsub(/<.*?>/, ''),
:length => 80) %></dd>
+ <% if product.date_available.past? %>
+ <dd>Available since <%= product.date_available %></dd>
+ <% else %>
+ <dd class="unavailable">Available from <%= product.date_available %></dd>
+ <% end %>
</dl>
</td>
<%= f.label :price %><br />
<%= f.text_field :price %>
</p>
- <p>
+ <p>
+ <%= f.label :date_available %><br />
+ <%= f.date_select :date_available, :order => [:day, :month, :year] %>
+ </p>
+<p>
<%= f.submit "Create" %>
</p>
<% end %>
<%=h @product.price %>
</p>
+<p>
+ <b>Date available:</b>
+ <%=h @product.date_available %>
+</p>
+
<%= link_to 'Edit', edit_product_path(@product) %> |
<%= link_to 'Back', products_path %>
--- /dev/null
+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
#
# 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"
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
margin: 0;
}
+#product-list .list-description .unavailable {
+ color: #f00;
+}
+
#product-list .list-actions {
font-size: x-small;
text-align: right;