sorry I misread your tables.  The has_many :through is looking for a
join table with ids for both sides which is the cause of the error,
same kind of table as a HABTM join table.

class Author < ActiveRecord::Base
    has_many :authorships
    has_many :books, :through => :authorships
  end

  class Authorship < ActiveRecord::Base
    belongs_to :author
    belongs_to :book
  end


On Aug 18, 3:43 pm, Rick R <[email protected]> wrote:
> On Wed, Aug 18, 2010 at 4:00 PM, Me <[email protected]> wrote:
> > oh you need to add the has_many for the join table
>
> > has_many :meter_goup
> > has_many :meters, :through => :meter_group
>
> I take it you mean on the Subscription table? which currently looks like:
>
> class Subscription < ActiveRecord::Base
>   belongs_to :user
>   belongs_to :meter_group
>   has_many :meters, :through => :meter_group
> end
>
> But a Subscription doesn't have many mete groups, a subscription can only be
> tied to a single meterGroup and has a fk to the meter_group table.
>
> Or are you saying for the other join table "meter_groups_meters" I need to
> make a MeterGroupsMeter model object and add the relationships you
> described?
>
> For reference The other relevant tables are:
>
> class Meter < ActiveRecord::Base
>   has_and_belongs_to_many :meter_groups
>   belongs_to :user
> end
>
> class MeterGroup < ActiveRecord::Base
>   belongs_to :user
>   has_and_belongs_to_many :meters
> end

-- 
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.

Reply via email to