It would be nice to add a method to the association proxy named the same 
way as the inverse_of option which allows traversal back to the owner 
object.

For example:

class Alphabet < ActiveRecord::Base
  has_many :letters, inverse_of: :alphabet
end
class Letters < ActiveRecord::Base
end

letters = Alphabet.first.letters
letters.alphabet #Return the alphabet object


This can currently be done by doing the following:
```ruby
class Alphabet < ActiveRecord::Base
  has_many :letters, inverse_of: :alphabet do
    def alphabet
      proxy_association.owner
    end
end
```

I guess it's not so hard to define this manually every time, but it would 
be a neat way to save some code, especially for occasions when you pass in 
a association (say to a view or authorisation object) and you want to get 
back the owner.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to