I cam across http://rails.lighthouseapp.com/projects/8994/tickets/
1677 yesterday.
In a nutshell it boils down to
Post.with_scope(:find => ...) { Post.some_scope.find :all }
returns posts scoped by both the call to with_scope and the call to
some_scope, but
Post.with_scope(:find => ...) { Post.some_scope}.find :all
returns posts only scoped by some_scope
Just like that it doesn''t look too bad: the find happens outside
with_scope''s block and so it doesn''t get scoped. Quel
surprise.
However it means that for example if we have
class Post
named_scope :base
def self.get_me_a_scope
base
end
end
then
some_user.posts.get_me_a_scope.find :all
will return posts from all users, which seems a bad thing.
http://gist.github.com/42383
seems to fix that particular but causes a failing test on
default_scope (which I haven''t really been following so I''m
not 100%
aware of what should and should not be)
Fred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---