Hi, Please tell me what values are you storing in the database for this 'time' field ? If your storing just %H:%M:%S values then I think you should be using this as your find query :
@bus_time = BusTime.find(*:all*, :order => "time", :conditions => ["time >= ? AND weekday = ?", *Time.now.strftime('%H:%M;%S')*, Date::DAYNAMES[Date.today.wday]]) So that the comparison is made appropriately in the SQL. Thanks & Regards, Dhruva Sagar. On Thu, Dec 3, 2009 at 3:26 PM, Terry6004 <nish.pa...@hotmail.com> wrote: > > Hi Mr Sagar, > > Yesterday i tried the code you helped me with which was: > > @bus_time = BusTime.find(:first, :order => "time", :conditions => ["time > >= ? AND weekday = ?", Time.now,Date::DAYNAMES[Date.today.wday]]) > > When this has to show 00:00:00 which is 12.00am it shows as nil and breaks > my app. So in the view i did this @bus_time.time.strftime("%H:%M") unless > @bus_time.time.nil? > > How do I show 00:00:00 > > > > > > > > > > > > Dhruva Sagar wrote: > > > > Hi, > > > > The following code seems to be more accurate to achieve what you want to > > do. > > > > <p> > > Station: > > <% if @train_time.station == "NMC" %> > > <p>By New Mills Central</p> > > <% else %> > > <p>By New Mills Newtown</p> > > <% end %> > > </p> > > > > Thanks & Regards, > > Dhruva Sagar. > > > > > > > > > > On Thu, Dec 3, 2009 at 2:43 PM, Terry6004 <nish.pa...@hotmail.com> > wrote: > > > >> > >> Hi all, I am a newbie trying to solve a simple IF statement problem in > my > >> show view. The code below is all about the station attribute where it > has > >> data which is either 'NMC' or 'NMN'. I want the view to show 'by new > mill > >> central if 'NMC' is true, but this does not work well as sometimes it > >> show > >> the wrong paragraph someone please help thanks > >> > >> [code] > >> <p> > >> Station: > >> <% if @train_time.station = "NMC" == true %> > >> <p>By New Mills Central</p> > >> <% else %> > >> <p>By New Mills Newtown</p> > >> <% end %> > >> </p> > >> > >> > >> [/code] > >> -- > >> View this message in context: > >> > http://old.nabble.com/Simple-IF-Statement-help-please-tp26622148p26622148.html > >> Sent from the RubyOnRails Users mailing list archive at Nabble.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-t...@googlegroups.com. > >> To unsubscribe from this group, send email to > >> rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com> > <rubyonrails-talk%2bunsubscr...@googlegroups.com<rubyonrails-talk%252bunsubscr...@googlegroups.com> > > > >> . > >> For more options, visit this group at > >> http://groups.google.com/group/rubyonrails-talk?hl=en. > >> > >> > >> > > > > -- > > > > 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-t...@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com> > . > > For more options, visit this group at > > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > > > > > > > -- > View this message in context: > http://old.nabble.com/Simple-IF-Statement-help-please-tp26622148p26623480.html > Sent from the RubyOnRails Users mailing list archive at Nabble.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-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.