Rails表单没有点击动作

时间:2016-08-12 14:39:46

标签: ruby-on-rails ajax forms routes

因此,我在Transactions(tx)控制器中创建了一个操作,以便通过API调用更新订单。表单位于购买确认页面及其ajax请求中。

def deduct_shipping_cost
  @transaction = Bid.find(params[:id]).tx
  if @transaction.update(transaction_params)
    @transaction.bid.shipping_cost = 0
    @transaction.bid.calculate_total_amount
    p @transaction.bid
    p ArmorPaymentsApi.update_order(@transaction.bid, "message" => "Buyer will be using their freight account #. Shipping costs that were quoted have been deducted from the order.")
  end
end

这是我控制器中的动作

post 'update_order' => 'transactions#deduct_shipping_cost', as: "deduct_shipping_cost"

这是路线

这里的形式是什么

.form-container
  = form_for(deduct_shipping_cost_path, html: { class: "inline-form" }, remote: true) do |f|
    .field.form-group.freight_num
      = f.text_field :shipping_account, class: "form-control", placeholder: "Account #"
    .actions.freight_num.send_ship_num{style: "margin-bottom: 20px;"}
      = f.submit 'Submit', class: "btn custom-btn"`

服务器显示我提交的数据,但它不会更新@transaction,也不会在控制器操作中执行任何操作

0 个答案:

没有答案