title: multiple joins in rails
body: <p>I am building a recipe app where a user can view recipes, list ingredients, get a shopping list, etc. etc.</p>
  
  <p>Each Recipe is made of steps, each step has ingredients, and each ingredient has a grocery.</p>
  
  <p>I was quite sure that the way to create these links was through the models, so my models look like this</p>
  
  <pre>
  class Recipe &lt; ActiveRecord::Base
      has_many :steps,    :dependent => :destroy
      has_many :ingredients, :through => :steps
      has_many :groceries, :through => :ingredients
  end
  
  class Step &lt; ActiveRecord::Base
    belongs_to :recipe
    has_many :ingredients, :dependent => :destroy
    has_many :groceries, :through => :ingredients
    accepts_nested_attributes_for :ingredients
  end
  
  class Ingredient &lt; ActiveRecord::Base
      belongs_to :step
      belongs_to :recipe
      has_one :grocery
  end
  
  class Grocery &lt; ActiveRecord::Base
      has_and_belongs_to_many :ingredients
          has_and_belongs_to_many :steps, :through => :ingredients
          has_and_belongs_to_many :recipes, :through => :ingredients
  end
  </pre>
  
  <p>I can output debug @recipe.steps, @recipe.ingredients, but @recipe.groceries returns</p>
  
  <pre>
  uninitialized constant Recipe::Grocery
  </pre>
  
  <p>I think this is an issue with the joins, but I don't see why I should need to specify the join in the controller. </p>
  
  <p>The controller is simply</p>
  
  <pre>
  def show
      @recipe = Recipe.find(params[:id])
  
      respond_to do |format|
        format.html # show.html.erb
        format.xml  { render :xml => @recipe }
      end
    end
  </pre>
  
  <p>Am i looking for my error in the right place? or am I misinterpreting the error??</p>