diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb
index 839e104..fa4b33f 100644
--- a/app/controllers/products_controller.rb
+++ b/app/controllers/products_controller.rb
@@ -17,6 +17,6 @@ class ProductsController < ApplicationController
end
end
def product_params
- return params.require(:product).permit(:name, :description)
+ return params.require(:product).permit(:name, :description, :weight)
end
end
diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb
index b2fb71f..fc5585f 100644
--- a/app/views/products/index.html.erb
+++ b/app/views/products/index.html.erb
@@ -5,8 +5,9 @@
<%= product.name %>
- <%= product.description %>
- <%= product %>
+ <%= product.description %>
+
+ <%= product.weight %>
<% end %>
diff --git a/app/views/products/new.html.erb b/app/views/products/new.html.erb
index e1ee3d6..b204088 100644
--- a/app/views/products/new.html.erb
+++ b/app/views/products/new.html.erb
@@ -10,5 +10,10 @@
name="product[description]"
placeholder="Product Description"
value="">
+
diff --git a/db/migrate/20151030122803_add_weight_to_products.rb b/db/migrate/20151030122803_add_weight_to_products.rb
new file mode 100644
index 0000000..d1e507f
--- /dev/null
+++ b/db/migrate/20151030122803_add_weight_to_products.rb
@@ -0,0 +1,5 @@
+class AddWeightToProducts < ActiveRecord::Migration
+ def change
+ add_column :products, :weight, :integer
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 05eee69..ca3fae3 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20151029235418) do
+ActiveRecord::Schema.define(version: 20151030122803) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -21,6 +21,7 @@ ActiveRecord::Schema.define(version: 20151029235418) do
t.string "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.integer "weight"
end
end