Permalink
Browse files

added availability column to products

  • Loading branch information...
1 parent 8aad782 commit 8d3d9b8953438c1a24530cef0ac6ac63cb6061d1 @florida committed Nov 14, 2012
@@ -1,4 +1,5 @@
class StoreController < ApplicationController
def index
end
+
end
View
@@ -3,7 +3,13 @@ class Product < ActiveRecord::Base
has_many :lineitems
validates :description, :presence => true
validates :name, :presence => true
- validates :price, :numericality => true, :presence => true
- validates :stock_no, :numericality => { :only_integer => true }
+ validates :price, :numericality => { :greater_than_or_equal_to => 0 }, :presence => true
+ validates :stock_no, :numericality => { :only_integer => true, :greater_than_or_equal_to => 0 }
validates :image_url, :presence => true, :format => { :with => %r{\.(gif|jpe?g|png)$}i }
+
+
+ def self.available_items
+
+ end
+
end
@@ -30,7 +30,10 @@
<section class="field">
<%= f.label :image_url %><br />
<%= f.text_field :image_url %>
-
+ </section>
+ <section class="field">
+ <%= f.label :availability %>
+ <%= f.check_box :availability %>
</section>
<section class="actions">
<%= f.submit %>
@@ -0,0 +1,5 @@
+class AddAvailabilityColumnToProducts < ActiveRecord::Migration
+ def change
+ add_column :products, :availability, :boolean
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20121114035955) do
+ActiveRecord::Schema.define(:version => 20121114042640) do
create_table "lineitems", :force => true do |t|
t.integer "product_id"
@@ -40,9 +40,10 @@
t.text "description"
t.float "price"
t.integer "stock_no"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
t.string "image_url"
+ t.boolean "availability"
end
create_table "users", :force => true do |t|

0 comments on commit 8d3d9b8

Please sign in to comment.