views:

63

answers:

1

I'm building an application that contains a bunch of projects that are at various stages, and I need to list the completed projects, or the projects that are at various other stages. So to list the completed projects, I name a scope;

named_scope :current, :conditions => { :current_stage => "Completed" }

and use;

@projects = Project.current

in my controller.

But I how do I find all the projects at other stages? I thought it would involve != but I can't get that to work.

Any pointers very much appreciated.

Thanks a lot

+4  A: 

This should work:

named_scope :incomplete, :conditions => [ 'current_stage != "Completed"' ]
Can Berk Güder
And so it does. Wahey!Thank you very much.
Mazonowicz
@Mazonowicz You should accept this answer by clicking the tick mark if this worked for you.
Anurag
@Mazonowicz: you're welcome.
Can Berk Güder
What about **current_stage** is nil ? How to include these in the results?
Sney