update search
This commit is contained in:
32
app/controllers/transactions/orders_controller.rb
Normal file
32
app/controllers/transactions/orders_controller.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
class Transactions::OrdersController < ApplicationController
|
||||
def index
|
||||
|
||||
filter = params[:filter]
|
||||
if filter.nil?
|
||||
orders = Order.order("order_id desc")
|
||||
else
|
||||
order = Order.search(filter)
|
||||
if order.count > 0
|
||||
orders = order
|
||||
else
|
||||
orders = Order.order("order_id desc")
|
||||
|
||||
end
|
||||
end
|
||||
@orders = Kaminari.paginate_array(orders).page(params[:page]).per(50)
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @orders }
|
||||
end
|
||||
end
|
||||
def show
|
||||
|
||||
@order = Order.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @order }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user