From what I can understand, I should be able to treat an anonymous
scope as an intermediary object with which to build queries on the
fly.
Following the procedure in Railscast episode 112 (http://
railscasts.com/episodes/112), I try the following (in script/console):
a = Production.scoped({})
Hitting return results in a call to the database and all (hundreds of
thousands) records returned.
Is this the expected behavior?
I was hoping to use this to add various scopes according to the search
parameters requested, but I can''t afford to do full table scans on
each step.
What could I be doing wrong?
Thanks for any ideas,
John
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On Aug 28, 3:52 am, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> From what I can understand, I should be able to treat an anonymous > scope as an intermediary object with which to build queries on the > fly. > > Following the procedure in Railscast episode 112 (http:// > railscasts.com/episodes/112), I try the following (in script/console): > > a = Production.scoped({}) > > Hitting return results in a call to the database and all (hundreds of > thousands) records returned. > > Is this the expected behavior? > > I was hoping to use this to add various scopes according to the search > parameters requested, but I can''t afford to do full table scans on > each step. > > What could I be doing wrong? >The console is fooling you: it''s trying to display a, and trying to display it causes the scope to be loaded. if you did a - Production.scoped({}); false (so what the console displays is just false) then you should be ok Fred> Thanks for any ideas, > > John--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That''s very good news. I''m just not up for a dive into the internals today. Thanks Frederick! On Aug 28, 2:48 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Aug 28, 3:52 am, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > From what I can understand, I should be able to treat an anonymous > > scope as an intermediary object with which to build queries on the > > fly. > > > Following the procedure in Railscast episode 112 (http:// > > railscasts.com/episodes/112), I try the following (in script/console): > > > a = Production.scoped({}) > > > Hitting return results in a call to the database and all (hundreds of > > thousands) records returned. > > > Is this the expected behavior? > > > I was hoping to use this to add various scopes according to the search > > parameters requested, but I can''t afford to do full table scans on > > each step. > > > What could I be doing wrong? > > The console is fooling you: it''s trying to display a, and trying to > display it causes the scope to be loaded. > if you did a - Production.scoped({}); false > (so what the console displays is just false) then you should be ok > > Fred > > > Thanks for any ideas, > > > John--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---