map.resources with habtm


In you subject line you say you are using has_and_belongs_to_many
(habtm) and in the body of your post you say you are using through. I
would first suggest that you don't confuse these two since they are
actually different.

I am going on the assumption that you have created a many-to-many
using has_many :through.

So you would have something like this:

class Recipe << ActiveRecord::Base
    has_many :recipe_ingredients
    has_may :ingrediants, :through => :recipe_ingredients

class Ingredient << ActiveRecord::Base
    has_many :recipe_ingredients
    has_many :recipes, :through => :recipe_ingredents

class RecipeIngredient << ActiveRecord::Base
    belongs_to :recipe
    belongs_to :ingredient

I would assume that a RecipeIngredient would have an additional column
to store the quantity of the ingredient for the recipe.

Now you question is about adding ingredients to a recipe. Well in
this case try to think about it as a simple CRUD operation. In
thinking about it this way you would "Create" a new RecipeIngredient
and assign it to a recipe and to an ingredient with something along
the line of: