2009/6/17 Hugues Brunelle <[email protected]>: > > 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 ===
@stack.products will give you an array of products then for each product, product.ingredients will give you an array of ingredients. Colin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

