has a field through an association

Hey guys,

Trying to figure out how to do something like the following:

class Child
     belongs_to :parent
     has_field :some_field, :through => :parent

class Parent
     has_one :child
     attr_accessible :some_field

child.some_field #=> parent.some_field
child.some_field = value #=> sets parent.some_field = value

I can of course accomplish this by adding custom accessors to Child, but looking for a better solution. I could also write a plugin that dynamically adds the accessors, but not sure if something already exists.

Thanks in advance,
Garrett Lancaster

It sounds like you're looking for something like delegate_belongs_to:


It does pretty much exactly what you've described.

--Matt Jones