# Query

**URL:** <https://www.ruby-forum.com/t/query/126965>\
**Category:** Rails\
**Created:** [January 23, 2008, 7:45pm UTC](https://www.ruby-forum.com/t/query/126965 "2008-01-23T19:45:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dotty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@dotty](https://www.ruby-forum.com/u/dotty)\
**Post date:** [January 23, 2008, 7:45pm UTC](https://www.ruby-forum.com/t/query/126965/1 "2008-01-23T19:45:39Z")

</div>

Hello everyone,

I’m learning RoR by creating a small web app that I use for work. I have  
the main model with which is Project(s) which has many Task(s) (of  
course belongs to Project) then a few other controller/models below  
that.  
When I list the tasks, I expect the Project id

def list  
@project = Project.find(params[:id])  
end

in my list.rhtml I currently just show every task with an each.do

\<%= @project.task.each do |t| %\>  
and then the code to display all my fields and records.

So, to make a long story short, I have a field called “Status” which has  
a few options, (New, In-Process, On-Hold, Completed). and what I want to  
be able to do is just show non completed tasks ie: != Completed)  
Then do some more html stuff and have a seperate section later to show  
the completed tasks. All with in the list.rhtml

I’ve tried a few different things I’ve found around the web, but nothing  
seems to work.

Cheers

BTW I am using V2.0.2 of everything

---

<div class="post-metadata">

**Author:** ![dotty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@dotty](https://www.ruby-forum.com/u/dotty)\
**Post date:** [January 23, 2008, 8:28pm UTC](https://www.ruby-forum.com/t/query/126965/2 "2008-01-23T20:28:16Z")

</div>

Kevin,

just do the if conditions inside the do loop

like  
\<%= @project.task.each do |t| %\>  
\<% if t.status != “Completed” %\>  
\<%=t.XXX%\>  
\<% end %\>  
\<% end %\>

On 24/01/2008, Kevin R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## def list a few options, (New, In-Process, On-Hold, Completed). and what I want to BTW I am using V2.0.2 of everything
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
“Smile while you cry.”

“There are only two tragedies in life: one is not getting what one  
wants,  
and the other is getting it.”

---

<div class="post-metadata">

**Author:** ![dotty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@dotty](https://www.ruby-forum.com/u/dotty)\
**Post date:** [January 23, 2008, 8:28pm UTC](https://www.ruby-forum.com/t/query/126965/3 "2008-01-23T20:28:52Z")

</div>

or you can try like this too inside loop

by

\<%= @project.task.each do |t| %\>  
\<%=t.XXX if t.status != “Completed”%\>  
\<% end %\>

On 24/01/2008, Bala [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \<% end %\>
> 
> > course belongs to Project) then a few other controller/models below  
> > and then the code to display all my fields and records.
> 
> –  
> “Smile while you cry.”
> 
> “There are only two tragedies in life: one is not getting what one wants,  
> and the other is getting it.”

–  
“Smile while you cry.”

“There are only two tragedies in life: one is not getting what one  
wants,  
and the other is getting it.”

---

<div class="post-metadata">

**Author:** ![dotty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@dotty](https://www.ruby-forum.com/u/dotty)\
**Post date:** [January 24, 2008, 12:05am UTC](https://www.ruby-forum.com/t/query/126965/4 "2008-01-24T00:05:38Z")

</div>

Or!

\<% for task in @project.tasks.select { |t| t.status != “Completed” } %\>  
#task stuff  
\<% end %\>

On Jan 24, 2008 7:19 AM, Kevin R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ## Thanks guys I tried that once, but I forgot the ""quotes around the Completed. I guess I should go get my eyes checked
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![dotty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@dotty](https://www.ruby-forum.com/u/dotty)\
**Post date:** [January 23, 2008, 9:49pm UTC](https://www.ruby-forum.com/t/query/126965/5 "2008-01-23T21:49:02Z")

</div>

Bala wrote:

> or you can try like this too inside loop
> 
> by
> 
> \<%= @project.task.each do |t| %\>  
> \<%=t.XXX if t.status != “Completed”%\>  
> \<% end %\>

Thanks guys I tried that once, but I forgot the ""quotes around the  
Completed. I guess I should go get my eyes checked
