Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Return associated records not proxies from readers of non-collection associations

#1855

When using association value in if/unless operators it's not possible to emulate nil value. So we used to load the associated record on first access and return nil if record wasn't found. Because records are always loaded eagerly there is no sence in using proxies for them.

The change is split in two patches. First patch moves association proxy class selection logic into association reflection. Second patch is the main change.

Reported by Aliaksey Kandratsenka · February 3rd, 2009 @ 06:49 AM

State: stale
Milestone: 3.1
Assigned to: Aaron Patterson Aaron Patterson
Importance: none

Activity

  1. Michael Koziarski
    Michael Koziarski
    • Assigned user set to Michael Koziarski

    I like this change, it indeed doesn't make any sense to return the proxy in this situation and it can lead to some weird crazy problems when your model uses the same method names as the proxy classes :)

    I want to hold off till 2.3 ships though just in case people have some .is_a? conditions or somethign lying around.

    Great work though

    February 6th, 2009 @ 01:42 AM

  2. Pratik
    Pratik
    • Tag changed from activerecord, association, associations, association_proxy to activerecord, association, associations, association_proxy, patch
    • Title changed from [PATCH] return associated records not proxies from readers of non-collection associations to Return associated records not proxies from readers of non-collection associations

    March 9th, 2009 @ 03:00 PM

  3. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Importance changed from to

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:41 PM

  5. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:41 PM

  6. Aliaksey Kandratsenka
    Aliaksey Kandratsenka

    From quick glimpse of rails 3 code base it seems to be still relevant. I.e. returning proxy from belong_to accessor stills makes little sense.
    Obviously, patch needs some rebasing. I'm not following Rails development for some time already, so if any of ticket watchers want to try rebasing this for rails 3, feel free.

    February 5th, 2011 @ 05:23 PM

  7. Santiago Pastorino
    Santiago Pastorino
    • State changed from stale to open

    February 5th, 2011 @ 08:30 PM

  8. Santiago Pastorino
    Santiago Pastorino
    • Milestone changed from 3.x to 3.1
    • Assigned user changed from Michael Koziarski to Aaron Patterson

    Thanks Aliaksey for re-opening.
    I'm assigning Aaron since he is working a lot on AR, also I'm pretty sure that he would like this change :).

    February 5th, 2011 @ 08:33 PM

  9. rails
    rails

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    May 7th, 2011 @ 01:00 AM

  10. rails
    rails
    • State changed from open to stale

    May 7th, 2011 @ 01:00 AM