Is there a "has_one ..., :through"?

I have found a few posts on various sites that this was something that
was going to be available. The posts were all over a year ago, but it
doesn’t seem like it is available in 1.2 unless I am missing something
(which I hope is true)

I have a member and office table that each have an address. Any
advice on the best way to do this. I have also seen a few posts
saying to use delegates, but without much info on how to do so and I
can’t find any info on delegates in the docs.

Any advice on the best way to make these relationships is appreciated.


On Nov 2, 10:03 am, chris [email protected] wrote:

Any advice on the best way to make these relationships is appreciated.


are these the posts youre talking about?

first 2 yes, last one no.

if I take the long approach of creating a get and set method, is there
a short way to make the association between the address and member
table without having to create a model out of the associative table?

class member

def address
if @address.nil?
@address = Address.find_by_member_id( unless

def address=(value)
@address = value

def after_insert
#connect the tables here


the guy who wrote the second article reference, Ryan H., is
working on a patch for Rails to add the has_one :through.

or there is this way, but now I have a address collection within the
model. It is rather difficult to believe that Rails would not have a
better way of making associations of this sort.

class Member
has_and_belongs_to_many :addresses, :join_table
=> :members_addresses

def address
return self.addresses[0] unless self.addresses.nil?

def address=(value)
self.addresses = [] if self.addresses.nil?
self.addresses << value

In my case I have an address table that is linked to a few tables
within the database. It turns out that in my case polymorphic
association is probably the best bet anyway.

Thanks for letting me know though, I am sure the plugin will come in
handy someday.