Hi --
After scouring these forums, the blogs, & wiki's I've finally decided to
ask the question because either nobody has encountered this problem or,
more likely, I I'm missing something obvious.I am attempting to access the extra attributes on the join model through
a has_many :through association. Most code examples I have found don't
deal with this situation even though, I think, that was part of decision
to deprecate HABTM in favor of HMT.I have tables "accounts", "links", and the join table "account_links".
In the end, I want to be able to do this:
a = Account.find(1)
a.links[0].label=> "untitled"
You're calling "label" on a Link object, but links don't have a label
field or attribute. So somewhere along the way you have to get hold of
the AccountLink object you want.
class Link < ActiveRecord::Base
has_many :account_links
has_many :account, :through => :account_links
That should be :accounts (plural), though I don't think it has a
direct bearing on the question you're asking.
David