I have a header menu with my cart in it. I don't know where I must write my query and show the items in the cart.
My shared views is in /views/shared/_header.html.erb and I can't find any solution for sending variable to it.
I have a header menu with my cart in it. I don't know where I must write my query and show the items in the cart.
My shared views is in /views/shared/_header.html.erb and I can't find any solution for sending variable to it.
Any action you request must query the items. Save the results and pass it to the view.
Try this:
render "shared/header", variable: @variable
Or
render partial: "shared/header", locals: { variable: @variable }