Sha256: 200faa73312dfdab1cdfff1d0996b51d01d3710a680749c792ab9dbe4101ba9b

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

class RailsTradeAdmin::OrderPaymentsController < RailsTradeAdmin::BaseController
  before_action :set_order
  before_action :set_payment_order, only: [:destroy]
  after_action only: [:create] do
    mark_audits(Order: [:payment_orders])
  end

  def index
    @payment_orders = @order.payment_orders
  end

  def new
    @payment_order = PaymentOrder.new
    @payments = @order.pending_payments
  end

  def create
    @payment_order = @order.payment_orders.build(payment_order_params)
    @order = @payment_order.order

    if @payment_order.save
      respond_to do |format|
        format.js
      end
    else
      render 'create_fail'
    end
  end

  def destroy
    if @payment_order.init?
      @payment_order.destroy
    end
    respond_to do |format|
      format.js
    end
  end

  private
  def set_payment_order
    @payment_order = PaymentOrder.find(params[:id])
  end

  def set_order
    @order = Order.find(params[:order_id])
  end

  def payment_order_params
    params.fetch(:payment_order, {}).permit(:payment_id, :check_amount)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_trade-0.0.1 app/controllers/the_trade_admin/order_payments_controller.rb