lundi 22 juillet 2019

Rails request.referer didnt redirect to the previous url

I am trying to redirect the canceled page to the previous one when the item's been canceled but at the moment the codes below don't work - can you help?

def destroy
  order.cancel

  respond_to do |format|
    format.html { redirect_to request.referer.include? "cancel" ? request.referer : order_path(order.shopify_id), notice: 'Order cancelled successfully!' }
  end
end

def cancel
  shopify_order.cancel

  fulfilment_orders.each do |fo|
    fo.update!(state: :cancelled) unless fo.state.in?(%i[shipped delivered could_not_deliver])
  end
end

Aucun commentaire:

Enregistrer un commentaire