# Manipulate HABTM relationships in views

**URL:** <https://www.ruby-forum.com/t/manipulate-habtm-relationships-in-views/170200>\
**Category:** Ruby\
**Created:** [June 13, 2009, 6:51pm UTC](https://www.ruby-forum.com/t/manipulate-habtm-relationships-in-views/170200 "2009-06-13T18:51:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hugues](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f04885/32.png) [@hugues](https://www.ruby-forum.com/u/hugues)\
**Post date:** [June 13, 2009, 6:51pm UTC](https://www.ruby-forum.com/t/manipulate-habtm-relationships-in-views/170200/1 "2009-06-13T18:51:20Z")

</div>

Hi everyone.  
I’m currently working on a bodybuilding supplement Website which have 3  
models :

- Stack :  
has\_and\_belongs\_to\_many :products
- Product :  
has\_and\_belongs\_to\_many :stacks  
has\_and\_belongs\_to\_many :ingredients
- Ingredient :  
has\_and\_belongs\_to\_many :products

Now what I am trying to do is list all the ingredients for a Stack  
(using standard params[:id]). It seems that I cannot pass multiple  
product\_ids (but one id work fine!) to get the ingredients listing.

Here’s a partial code from my controller :

=== START ===

def stack  
begin  
@stack = Stack.find(params[:id])  
render :template =\> “public/stack\_#{@lang}”  
rescue ActiveRecord::RecordNotFound  
logger.error(“Attempt to access invalid stack #{params[:id]}”)  
flash[:notice] = “DÃ©solÃ©, cette formule est introuvable.”  
redirect\_to :action =\> :index  
end  
end

=== END ===

Any help would be appreciate and I can provide more information if my  
request isn’t clear enought.

I am using RAILS\_GEM\_VERSION = ‘1.2.6’

Thanks

Hugues
