To pay the tutor.
# File app/controllers/transactions_controller.rb, line 14 def create @transaction = Transaction.new(transaction_params.merge(from_user_id: current_user.id)) if current_user.has_balanced_account? respond_to do |format| if @transaction.valid? if Payment.populate_credits(@transaction) @transaction.charged = true @transaction.save if @transaction.pay_tutor flash[:notice] = 'Payment is successful.' format.js {} else format.js {render partial: 'form', replace: 'form#new_transaction'} end else format.js {render partial: 'form', replace: 'form#new_transaction'} end else format.js {render partial: 'form', replace: 'form#new_transaction'} end end else respond_to do |format| format.js {} end end end
It render transaction form to pay.
# File app/controllers/transactions_controller.rb, line 8 def new @transaction = Transaction.new render layout: false end