Query

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

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. [email protected] 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/.


“Smile while you cry.”

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

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 [email protected] 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.”

Or!

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

On Jan 24, 2008 7:19 AM, Kevin R. [email protected]
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/.


Ryan B.
http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs