在我的ruby应用程序中,我有一个控制器功能,以减少购物车中的产品数量。
def decrease
quantity = change_quantity(-1)
render json: { quantity: quantity, total:current_order.display_item_total }
end
在视图文件中,减少按钮的调用如下:
.quantity_changer
= link_to decrease_order_path(line_item.id), method: :post, remote: true, class: 'cart-item-change minus' do
%i.fa.fa-minus
在这里,如何在减少操作后重新加载页面。
我试过添加
redirect_to :back
但它没有用。
请帮我解决这个问题..
如果您使用的是rails 5,则只有一个重定向方法可用于此目的。 redirect_back(fallback_location: root_path,notice: "your notice here")