# Cart relationated with id

**URL:** <https://www.ruby-forum.com/t/cart-relationated-with-id/182260>\
**Category:** Rails\
**Created:** [January 25, 2010, 6:44pm UTC](https://www.ruby-forum.com/t/cart-relationated-with-id/182260 "2010-01-25T18:44:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nexon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b5a626/32.png) [@nexon](https://www.ruby-forum.com/u/nexon)\
**Post date:** [January 25, 2010, 6:44pm UTC](https://www.ruby-forum.com/t/cart-relationated-with-id/182260/1 "2010-01-25T18:44:28Z")

</div>

Hi, I want to make a cart that actually I initialize with my session. It  
works right and one user has one cart but… If I want to make differents  
carts for differents controllers?

I have the plugin acts\_as\_tree and I have a whos\_controller that has  
many products. These products can add to cart and in every  
whos\_controller in the show view I show the cart and I can add more  
items to cart. I want to show a cart for whos/1, a different cart for  
whos/2…

I don’t know if you understand me… It’s complicated for me explain it.

Actually I have initialized the cart like this:

def find\_cart  
@cart = (session[:cart] ||= Cart.new)  
end

And I have a model cart.rb

My answer is very complicated? or is a simple initialization of cart?

thanks.
