This project is archived and is in readonly mode.
ActiveRecord::Base#exists? raises exception when using :include in default_scope
Reported by yipdw | October 13th, 2010 @ 06:10 PM
When using default_scope
containing
:include
, ActiveRecord::Base#exists?
raises a ActiveRecord::MissingAttributeError
.
A demonstration of the error for ActiveRecord 2.3.9 is available here:
http://gist.github.com/624421/4735425e696993b7d409c7cb8b77878461712881
A demonstration of the error for ActiveRecord 3.0.0 is available here:
https://gist.github.com/624421/417c372a474a16566989261c8e0f9944fe32...
Neither of these are proper automated test cases, but it should be possible to fit them into ActiveRecord's test suite without too much difficulty.
This error appears to be related to the change introduced by #2543. Robin Salkeld's comment on #2543 (https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets...) seems especially relevant.
Comments and changes to this ticket
-
yipdw October 13th, 2010 @ 06:12 PM
URL scheme goof:
https://gist.github.com/624421/417c372a474a16566989261c8e0f9944fe32...
should be (for consistency)
http://gist.github.com/624421/417c372a474a16566989261c8e0f9944fe3268ae
-
Ryan Bigg October 13th, 2010 @ 09:39 PM
- State changed from new to incomplete
- Importance changed from to Low
Please attach a patch with a failing test to this ticket by following the "Contributing to Rails" guide.
-
Jonathan Julian November 18th, 2010 @ 04:35 AM
This also raises when
exists?
is called on an association with an:include
. Note that it only raises when it should return true. ActiveRecord 3.0.2A workaround, if you can use an id to check for existence:
model.collection_singular_ids.include?(associated_id)
-
rails March 29th, 2011 @ 01:00 AM
- State changed from incomplete to open
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 March 29th, 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>