B
B
Breezy
Search…
Updating shopping cart
You want to update a cart count located in the header when a user clicks on "Add to cart" on a product listing.
1
<form action='/add_to_cart?bzq=data.header.cart' method='POST' data-bz-remote={true}>
Copied!
1
def create
2
... add to cart logic here...
3
4
# This helper will retain the `bzq` param when redirecting, which allows the
5
# partial rendering of the `show` page.
6
redirect_back_with_bzq fallback_url: '/'
7
end
Copied!
The above will POST, and get redirected back to the original page while fetching only the header to update.
Last modified 3mo ago
Copy link