Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7931723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:48:28+00:00 2026-06-03T20:48:28+00:00

It looks like association extensions have changed quite a bit throughout Rails 3.x. I

  • 0

It looks like association extensions have changed quite a bit throughout Rails 3.x.

I need to access the proxy owner and the proxy target (i.e, the has_many object and the belongs_to object).

The most recent documentation says To use proxy_association.owner and proxy_association.target. However, this throws an method missing. I found some older references (can’t find them now), saying that self.proxy_target would work. However this only seems to work intermittently and isn’t reliable between my local environment and production (strange… I know).

Does anybody know where I can find more definitive answer on how to access the owner and target from within an association extension using Rails 3.0.10?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:48:29+00:00Added an answer on June 3, 2026 at 8:48 pm

    proxy_association is new in rails 3.1. The rails 3.0.x (and 2.x) equivalent is proxy_owner and proxy_target. However proxy_target returns the instance variable that caches the association if it has been loaded, i.e. if the association has not yet been loaded you’d get back [] for a collection association. Or in other words, given

    class Bar < ActiveRecord::Base
      has_many :foos do
        def target_test
          proxy_target
        end
      end
    end
    

    then

    bar = Bar.first
    bar.foos.target_test #=> []
    bar.foos.inspect
    bar.foos.target_test #=> [#<Foo id: 1 ...>]
    

    You can force the target to be loaded by calling load_target before calling proxy_target. That all set I’m not sure why this is important – if you call stuff on self it will be forwarded to the target for you

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model that looks like this, the #friends method overrides the association-generated
I have a rails 3 app with paperclip. The model looks a little like:
Simple Rails question. I have a model Foo which looks like this: class Foo
According to the documentation Rails has_many association has clear method. Looks like it executes
I have an associative array which when var dumped looks like this: Array (
I have a hierarchically nested associative array. It looks like this: A = {
Looks like operator new and operator new[] have exactly the same signature: void* operator
I have a Questions table which looks like that as you see, there are
I have a class that looks like this: class SearchService include Mongoid::Document key :name,
I have a HABTM association between Users and Groups in my Rails 3 app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.