Re: unscoped...

If you have a default_scope in your model, unscoped ignores it.

Eg.
model/user.rb
default_scope :conditions => {'state' => 'enabled'}

All active record queries will automatically get the default scope.

Occassionally you want don't want the default scope.
That's when you used unscoped.  active record queries inside unscoped
don't get the default scope....
- User.unscoped do
  - User.all.each....


On Oct 9, 4:11 am, Nathan Weizenbaum <[email protected]> wrote:
> What exactly does unscoped do?
>
>
>
> On Fri, Oct 8, 2010 at 1:03 PM, andywatts <[email protected]> wrote:
> > I'm also seeing this with an unscoped block..
>
> > = MyClass.unscoped do
> >  - link_to '123', '/123'
>
> > Starting rails in production mode using `rails s -e production`.
>
> > - Andy
>
> > On Aug 20, 7:30 am, Nathan Weizenbaum <[email protected]> wrote:
> > > If you can provide me with a minimal reproducible case where it's not
> > acting
> > > right, I'll look into it.
>
> > > On Thu, Aug 19, 2010 at 4:26 PM, Serenity <[email protected]> wrote:
> > > > I tried changing it to =, and I got a huge glob of escaped html
> > > > showing up right in my web page - in addition to the contents of the
> > > > block.
>
> > > > I actually did not see that warning in this case, although I've seen
> > > > it in other cases.
>
> > > > On Aug 20, 12:03 am, Nathan Weizenbaum <[email protected]> wrote:
> > > > > In Rails 3, all block helpers are supposed to use =, not -. There
> > should
> > > > be
> > > > > a warning to that effect in your log; are you seeing that?
>
> > > > > On Thu, Aug 19, 2010 at 2:26 PM, Serenity <[email protected]> wrote:
> > > > > > Ok, so I have isolated the two different problems.
>
> > > > > > The crash was coming from a use of logger.silence - that is
> > apparently
> > > > > > what behaves differently in production than development.
>
> > > > > > The double render is coming from a use of with_options, like so:
>
> > > > > > - with_options :onclick => 'qsChooseForm(this)', :class => 'button'
> > do
> > > > > > |src_button|
> > > > > >  %p= src_button.link_to(params)
> > > > > >  %p= src_button.link_to(params)
> > > > > >  %p= src_button.link_to(params)
>
> > > > > > Is there a different syntax for something like this in haml now?
>
> > > > > > And I certainly have no idea why it's different in production vs.
> > > > > > development. Any thoughts on that?
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > "Haml" group.
> > > > > > To post to this group, send email to [email protected].
> > > > > > To unsubscribe from this group, send email to
> > > > > > [email protected]<haml%[email protected]>
> > <haml%[email protected]<haml%[email protected]>
> > ><
> > > > haml%[email protected]<haml%[email protected]>
> > <haml%[email protected]<haml%25252bunsubscr...@googlegroups. 
> > com>
>
> > > > >.
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/haml?hl=en.
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Haml" group.
> > > > To post to this group, send email to [email protected].
> > > > To unsubscribe from this group, send email to
> > > > [email protected]<haml%[email protected]><
> > haml%[email protected]<haml%[email protected]>
> > >.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/haml?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Haml" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected] <haml%[email protected]>.
> > For more options, visit this group at
> >http://groups.google.com/group/haml?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/haml?hl=en.

Reply via email to