From b5b2b829c60c0a7d91ee0ef75b43a62919e873f6 Mon Sep 17 00:00:00 2001 From: May Zin Oo Date: Mon, 5 Mar 2018 11:27:20 +0630 Subject: [PATCH] add two select box --- app/controllers/batches_controller.rb | 4 ++-- app/views/batches/_form.html.erb | 10 +++++++++- db/schema.rb | 1 - 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/batches_controller.rb b/app/controllers/batches_controller.rb index 4ea6a0f..01a85f4 100644 --- a/app/controllers/batches_controller.rb +++ b/app/controllers/batches_controller.rb @@ -21,6 +21,8 @@ class BatchesController < ApplicationController def new @batch = Batch.new + @clients=Client.all.order('id desc') + @product=ProductCategory.all.order('id desc') end def edit @@ -30,12 +32,10 @@ class BatchesController < ApplicationController def create date = DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d") order_ref = params[:batch][:order_ref] - puts order_ref adult_or_child=params[:adult_or_child] client_id=params[:client_id] product_category_id=params[:product_category_id] @batch = Batch.create_batch(date,order_ref,2,"adult_or_child",6,3) - puts @batch.order_ref respond_to do |format| if @batch.save diff --git a/app/views/batches/_form.html.erb b/app/views/batches/_form.html.erb index 6d646db..81f8d79 100644 --- a/app/views/batches/_form.html.erb +++ b/app/views/batches/_form.html.erb @@ -16,7 +16,15 @@ <%= f.input :order_ref ,:label =>false,:error => false,:placeholder =>'Please enter name',input_html: { class: "form-control" } %> <%= f.error :order_ref ,style: 'color: red' %> - + +
+ + <%= select_tag "client", options_from_collection_for_select(@clients, "id", "name"), :class => 'form-control'%> +
+
+ + <%= select_tag "product", options_from_collection_for_select(@product, "id", "name"), :class => 'form-control'%> +
diff --git a/db/schema.rb b/db/schema.rb index f80e7ec..4ddc3a3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -14,7 +14,6 @@ ActiveRecord::Schema.define(version: 20180226100816) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - enable_extension "uuid-ossp" create_table "batch_line_items", force: :cascade do |t| t.integer "batch_id"