From aebb20f8b4e29abdc7140800619ec94326d6341b Mon Sep 17 00:00:00 2001 From: Adrian Li Date: Sun, 6 Nov 2016 23:37:00 -0500 Subject: [PATCH 1/2] fix form validation error (category_id instead of just category) --- app/views/admin/products/new.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/products/new.html.erb b/app/views/admin/products/new.html.erb index aa33513ca9..9e919bc941 100644 --- a/app/views/admin/products/new.html.erb +++ b/app/views/admin/products/new.html.erb @@ -35,7 +35,7 @@
<%= form.label :category %> - <%= form.select :category, options_from_collection_for_select(Category.all.order(:name), :id, :name), { include_blank: true }, class: 'form-control' %> + <%= form.select :category_id, options_from_collection_for_select(Category.all.order(:name), :id, :name), { include_blank: true }, class: 'form-control' %>
From 8ad451b5a0df5033a111b8063f2b989c94ba0960 Mon Sep 17 00:00:00 2001 From: Adrian Li Date: Sun, 6 Nov 2016 23:37:21 -0500 Subject: [PATCH 2/2] fix typo in controller so redirect works properly after product creation --- app/controllers/admin/products_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/products_controller.rb b/app/controllers/admin/products_controller.rb index 9551c2b680..d1986b4abc 100644 --- a/app/controllers/admin/products_controller.rb +++ b/app/controllers/admin/products_controller.rb @@ -12,7 +12,7 @@ def create @product = Product.new(product_params) if @product.save - redirect_to [:admin, products], notice: 'Product created!' + redirect_to [:admin, :products], notice: 'Product created!' else render :new end