Hey man,

I used something like this with great success! (so far... since I just
used like few minutes ago, nothing broke and all test passed)  In
Rails 2.2.2

  class << self
    def find(*args)
      args.first == :all ? self.with_scope(:find => {:conditions =>
[:published => true]}) {super} : super
    end
  end

Do test it out if you still need to. And anyone else could comment if
this is the right way to do it.

Cheers!
Arzumy MD

On Apr 29, 1:19 am, Commander Johnson <[email protected]>
wrote:
> I did use that initially, but it broke my associations. After all it was the
> least work to just stick with a named_scope and double-check frontend
> controllers for not showing unpublished items.
>
> On Sat, Apr 25, 2009 at 4:57 PM, Frederick Cheung <
>
> [email protected]> wrote:
>
> > On Apr 25, 3:18 pm, Commander Johnson <[email protected]>
> > wrote:
> > > Indeed!
>
> > > named_scope :only_published, :conditions => { :published => true }
>
> > If you're on 2.3 you may also be interested in the default_scope stuff
> > that was recently added.
>
> > Fred
> > > On Sat, Apr 25, 2009 at 2:48 PM, Phlip <[email protected]> wrote:
>
> > > > Commander Johnson wrote:
>
> > > > > I want the find(:all) method to only return published Comments.
>
> > > > Use a named_scope. It's too easy like that.
>
> > > > --
> > > >   Phlip
> > > >  http://flea.sourceforge.net/resume.html
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to