This project is archived and is in readonly mode.
ActiveRecord :inverse_of doesn't have any effect
-
Jeremy Kemper
- Milestone set to 2.3.9
- State changed from new to open
-
Tor Erik
- Importance changed from to Low
Note that it works as expected
car.drivers.firstis changed to
car.drivers.to_a.first -
Tor Erik
(... it works as expected IF)
-
Santiago Pastorino
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
- State changed from open to stale
-
holli
- State changed from stale to open
Still open. Noticed it in my code using rails 3.0.3. I did also try it with using the code from above ( http://gist.github.com/445969 ).
Seems like fetching all with .to_a without any other options is the only way to get expected results.
Car.find(1).drivers.first.car # Car Load (0.2ms) SELECT "cars".* FROM "cars" WHERE ("cars"."id" = 1) LIMIT 1 # Driver Load (0.2ms) SELECT "drivers".* FROM "drivers" WHERE ("drivers".car_id = 1) LIMIT 1 # Car Load (0.1ms) SELECT "cars".* FROM "cars" WHERE ("cars"."id" = 1) LIMIT 1 # This works as excepted, no new query => Car.find(1).drivers.to_a.first.car # Car Load (0.4ms) SELECT "cars".* FROM "cars" WHERE ("cars"."id" = 1) LIMIT 1 # Driver Load (0.3ms) SELECT "drivers".* FROM "drivers" WHERE ("drivers".car_id = 1) Car.find(1).drivers.order('id').to_a.first.car # Car Load (0.1ms) SELECT "cars".* FROM "cars" WHERE ("cars"."id" = 1) LIMIT 1 # Driver Load (0.2ms) SELECT "drivers".* FROM "drivers" WHERE ("drivers".car_id = 1) ORDER BY id # Car Load (0.2ms)[state:open]
-
Santiago Pastorino
- Milestone changed from 2.3.10 to 3.1