This project is archived and is in readonly mode.
small enhancement to query scopes
-
toby cabot
- Tag set to patch
Here's a small patch that allows this behavior. It adds a special case to the scope processing (there were already 3 cases so this isn't a big change) that avoids the merge when the result of the scope is a single AR model object.
-
toby cabot
- Tag changed from patch to activerecord rails3, patch
-
rails
- State changed from new 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
- State changed from open to stale
-
Jeff Gardner
I'm still having this issue with rails 3.0.5. There is a patch above, can that be pulled into the main codebase?
-
toby cabot
- Tag cleared.
- State changed from stale to open
[state:open]
This is a small but, I think, worthwhile change to make Rails scopes a little more forgiving to new users.
I've rebased the patch (5960-2.diff) so it applies cleanly to 7bd70dc.
-
greg.silcox (at cumulosity)
I'm also having this problem in rails 3.0.5. My scope looks a lot like the example given above:
class StudentSession < ActiveRecord::Base
scope :last_updated, lambda { |user_id, group_id|where( :student_id => user_id, :group_id => group_id ). StudentSession.order( :updated_at ).first }end
It seems to only happen when I have a single record that matches.
