Understanding this Shopping Cart thing - rails4

Hey folks,
I was wondering what would be the best approach for this situation.
In my application layout I’ve got a partial which shows the user’s cart if there is any.

- if @cart && !@cart.line_items.empty?
%h1 Your Cart
= render @cart

However, if I want to, for instance, click on the button to show me this particular product details (/product/22), a NilException is thrown as I would’ve lost @cart object on the request.
I managed to fix it by adding this piece of code to the product’s controller:

before_action :load_current_cart, only: [:show]

def load_current_cart***@cart = current_cart***end

Is there a better/clean way to do it?
Thanks in advance

I’ve been using http://cells.rubyforge.org for this sort of stuff - keeps that sort of data thing where closer to the thing that actually uses it rather than it being scattered across all the controllers that might need it.

Fred