Class: RightnowOms::OrdersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RightnowOms::OrdersController
- Defined in:
- app/controllers/rightnow_oms/orders_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/rightnow_oms/orders_controller.rb', line 18 def create @order = Order.new_with_items(prepare_order) respond_to do |format| if @order.save @cart.destroy if @cart format.html { redirect_to @order } format.json { render_for_api :default, json: @order, root: :order, status: :ok } else format.html { redirect_to ::RightnowOms.config.new_order_url } format.json { render json: @order.errors, status: :unprocessable_entity } end end end |
#index ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'app/controllers/rightnow_oms/orders_controller.rb', line 5 def index orders = Order.search(params[:q]) orders.sorts = "created_at desc" respond_to do |format| format.json { render_for_api :default, json: orders.result, root: :orders, status: :ok } end end |
#show ⇒ Object
14 15 16 |
# File 'app/controllers/rightnow_oms/orders_controller.rb', line 14 def show @order = Order.find(params[:id]) end |