On Friday 15 May 2009, Branko Vukelic wrote: > On May 15, 9:20 pm, Michael Schuerig <mich...@schuerig.de> wrote: > > doesn't help, because you're not *creating* ingredients with > > associated ingredient_nutrients. Rather, you're associating > > existing ingredients and nutrients with the help of > > ingredient_nutrients. > > I'm starting to think this might be a design problem... > > Back to square 1, what I'm trying to do is the following: > > I have a bunch of _nutrients_ which are defined by their `name` and > the `units` used to measure them. I have _ingredients_ that are > defined by their `name`, and some meta data irrelevant for this > setup. Finally I wish to be able to enter the ingredients and > associated nutritional information (i.e., the nutrients and their > quantities) in one go.
You're not saying what doesn't work with your code as it is. > The snippet from the Ingredients controller: > > def new > @ingredient = Ingredient.new > for nutrient in Nutrient.all > @ingredient.nutritions.build :nutrient_id => nutrient.id # > <-- this is probably bad? You could just write @ingredient.nutritions.build(:nutrient => nutrient) Michael -- Michael Schuerig mailto:mich...@schuerig.de http://www.schuerig.de/michael/ --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---