This project is archived and is in readonly mode.

#1855 ✓stale
Aliaksey Kandratsenka

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

Reported by Aliaksey Kandratsenka | February 3rd, 2009 @ 06:49 AM | in 3.1

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.

Comments and changes to this ticket

  • Michael Koziarski

    Michael Koziarski February 6th, 2009 @ 01:42 AM

    • 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

  • Pratik

    Pratik March 9th, 2009 @ 03:00 PM

    • 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”
  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:41 PM

    • 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.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:41 PM

    • State changed from “open” to “stale”
  • Aliaksey Kandratsenka

    Aliaksey Kandratsenka February 5th, 2011 @ 05:23 PM

    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.

  • Santiago Pastorino

    Santiago Pastorino February 5th, 2011 @ 08:30 PM

    • State changed from “stale” to “open”
  • Santiago Pastorino

    Santiago Pastorino February 5th, 2011 @ 08:33 PM

    • 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 :).

  • rails

    rails May 7th, 2011 @ 01:00 AM

    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.

  • rails

    rails May 7th, 2011 @ 01:00 AM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages