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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Rie
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> 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
> --
> 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."
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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 <mbbala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> 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 Rie
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:
> >
> >
> > 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
> > --
> > 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."
--
"Smile while you cry."
"There are only two tragedies in life: one is not getting what one wants,
and the other is getting it."
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Or!
<% for task in @project.tasks.select { |t| t.status != "Completed"
} %>
#task stuff
<% end %>
On Jan 24, 2008 7:19 AM, Kevin Rie
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:
>
> 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
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--
Ryan Bigg
http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---