title: Rails: trying to create a has_many relationship from two tables to one table
body: <p>I have two models with associated tables (villa_rooms &amp; homes). Both have rates associated with them. I would like to use just one "rates" model with associated table to store rates for both villa_rooms and houses.</p>
  
  <p>I have created the following for villa_rooms, but it is not finding associated rates:</p>
  
  <pre><code>class VillaRoom &lt; ActiveRecord::Base
    has_many :villa_room_rates
    has_many :rates, :through =&gt; :villa_room_rates
  end
  
  class VillaRoomRates &lt; ActiveRecord::Base
    belongs_to :villa_room
    belongs_to :rate
  end
  
  class Rate &lt; ActiveRecord::Base
    has_one :villa_room_rate
    has_one :villa_room, :through =&gt; :villa_room_rates
  end
  </code></pre>
  
  <p>When I try to run VillaRoom.find(1).rates I get the following error </p>
  
  <pre><code>NameError: uninitialized constant VillaRoom::VillaRoomRate
  </code></pre>
  
  <p>Any help is greatly appreciated.</p>
  
  <p>Thanks!</p>