This project is archived and is in readonly mode.
unscoped on a relation removes where clause for relation from scope
-
bterkuile
The best behaviour would be: Corporation.first.facilities.without_default_scope.to_sql => SELECT "facilities".* FROM "facilities" WHERE ("facilities".entity_id = 2)
That would make this ticket a feature request.
-
Zachery Hostens
- Tag changed from activerecord relation, arel, unscoped to activerecord relation, arel, rails3.0.1, unscoped
this would be fine and dandy. except for that method does not exist. Note this is
Rails 3.0.1ruby-1.9.2-p0 > Corporation.first.facilities.without_default_scope.to_sql NoMethodError: undefined method `without_default_scope' for #<Class:0x00000102a87980> ruby-1.9.2-p0 > Corporation.first.facilities.scoped.without_default_scope.to_sql NoMethodError: undefined method `without_default_scope' for #<ActiveRecord::Relation:0x000001014fbd00> -
Santiago Pastorino
- Importance changed from to Low
Zanchery, can you provide a patch or a failing test case?
-
Zachery Hostens
I will look at writing a test case or two and possibly a patch, though it might be a couple days. Im going out of town this weekend, but will try to get to it as soon as possible.
-
Santiago Pastorino
Zachery: great!
-
bterkuile
I created a fix for an issue specific to my problem where i manually removed scopes and add them later again when the rest of the query was build. This is not a nice solution, but it works. This method can be used to construct a without_default scope storing the default scopes and removing them from where_values, etc. The code for this is at:
https://github.com/bterkuile/delete_softly/blob/master/lib/class_me... -
Santiago Pastorino
- State changed from new to open
- Tag changed from activerecord relation, arel, rails3.0.1, unscoped to activerecord relation, arel, rails301, unscoped
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