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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> 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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> To unsubscribe from this group, send email to > >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > > >> . > >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
BTW %H:%M:%S should show 00:00:00 time as well if that is what it is since %H is for 24 hour time and so on. Thanks & Regards, Dhruva Sagar. On Thu, Dec 3, 2009 at 3:26 PM, Terry6004 <nish.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> 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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> To unsubscribe from this group, send email to > >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > > >> . > >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Mr Sagar, I ran that query in my console and it returned an array of times etc so i will post one line to you which is: #<BusTime id: 97, weekday: "thursday", time: "2000-01-01 11:29:00", created_at: nil, updated_at: nil> Dhruva Sagar wrote:> > 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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> 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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> >> To unsubscribe from this group, send email to >> >> >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> > >> >> . >> >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > To unsubscribe from this group, send email to >> > >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-tp26622148p26624149.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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Mr Sagar, I ran that query in my console and it returned an array of times etc so i will post one line to you which is: #<BusTime id: 97, weekday: "thursday", time: "2000-01-01 11:29:00", created_at: nil, updated_at: nil> Dhruva Sagar wrote:> > BTW %H:%M:%S should show 00:00:00 time as well if that is what it is since > %H is for 24 hour time and so on. > > Thanks & Regards, > Dhruva Sagar. > > > > > On Thu, Dec 3, 2009 at 3:26 PM, Terry6004 <nish.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> 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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> >> To unsubscribe from this group, send email to >> >> >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> > >> >> . >> >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > To unsubscribe from this group, send email to >> > >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-tp26622148p26624157.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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Terry6004 wrote:> > Hi Mr Sagar, > > I ran that query in my console and it returned an array of times etc so i > will post one line to you which is: > > #<BusTime id: 97, weekday: "thursday", time: "2000-01-01 11:29:00", > created_at: nil, updated_at: nil> > > Please note that the time attribute is time:time not datetime but rails > still gives me 2000-01-01 for some reason > > > Dhruva Sagar wrote: >> >> 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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> 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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> >>> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> >> To unsubscribe from this group, send email to >>> >> >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >>> <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >>> > >>> >> . >>> >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> > To unsubscribe from this group, send email to >>> > >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >>> . >>> > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >>> . >>> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> 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-tp26622148p26624172.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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2009/12/3 Terry6004 <nish.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>:> > > > Terry6004 wrote: >> >> Hi Mr Sagar, >> >> I ran that query in my console and it returned an array of times etc so i >> will post one line to you which is: >> >> #<BusTime id: 97, weekday: "thursday", time: "2000-01-01 11:29:00", >> created_at: nil, updated_at: nil> >> >> Please note that the time attribute is time:time not datetime but rails >> still gives me 2000-01-01 for some reason >>There is no time of day class in ruby, the Time class (confusingly) includes the date, which seems to be set to 2000-01-01 if only a time of day is provided. Either you must cope with this in your application or you must store the time of day in some other form such as integer seconds into the day or as a string for example. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
good taime iam maryam my phone has danger there is iran i not wey On Dec 3, 2:11 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> 2009/12/3 Terry6004 <nish.pa...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>: > > > > > > > Terry6004 wrote: > > >> Hi Mr Sagar, > > >> I ran that query in my console and it returned an array of times etc so i > >> will post one line to you which is: > > >> #<BusTime id: 97, weekday: "thursday", time: "2000-01-01 11:29:00", > >> created_at: nil, updated_at: nil> > > >> Please note that the time attribute is time:time not datetime but rails > >> still gives me 2000-01-01 for some reason > > There is no time of day class in ruby, the Time class (confusingly) > includes the date, which seems to be set to 2000-01-01 if only a time > of day is provided. Either you must cope with this in your > application or you must store the time of day in some other form such > as integer seconds into the day or as a string for example. > > Colin-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
In the create action of the controller where you create your bus_time record, I would suggest you to do this . Please change the following code as per your application code. params[:bus_time][:time] = Date.parse(params[:bus_time][:time]) The above code will ensure that the appropriate Date is created from the input time (appending today''s date to it). Secondly you need to get your query back to how it was with *Time.now* being used instead of what I had changed it to. But in your view you should be doing @bus_time.time.strftime(''%H:%M:%S'') if @bus_time.time. That should output 00:00:00 appropriately when it is that. Thanks & Regards, Dhruva Sagar. On Thu, Dec 3, 2009 at 4:30 PM, Terry6004 <nish.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> > > > Terry6004 wrote: > > > > Hi Mr Sagar, > > > > I ran that query in my console and it returned an array of times etc so i > > will post one line to you which is: > > > > #<BusTime id: 97, weekday: "thursday", time: "2000-01-01 11:29:00", > > created_at: nil, updated_at: nil> > > > > Please note that the time attribute is time:time not datetime but rails > > still gives me 2000-01-01 for some reason > > > > > > Dhruva Sagar wrote: > >> > >> 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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > 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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > >>> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >>> >> To unsubscribe from this group, send email to > >>> >> > >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > > >>> <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > <rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%25252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > > >>> > > >>> >> . > >>> >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >>> > To unsubscribe from this group, send email to > >>> > > >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > > >>> . > >>> > 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > >>> To unsubscribe from this group, send email to > >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > > >>> . > >>> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> To unsubscribe from this group, send email to > >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > >> 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-tp26622148p26624172.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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
There is no worry about creation as all i am trying to do is to read information created from the database. I inputted the data via sql statements which was quicker as i have so many records I will not be creating any new records all I need to do is display it, but displaying all those records is proving to be difficult as there are so many records and scaffolding does is not appropriate for views I am getting: monday time monday time monday time tuesday time tuesday time tuesday time It is a nightmare.... Dhruva Sagar wrote:> > In the create action of the controller where you create your bus_time > record, I would suggest you to do this . Please change the following code > as > per your application code. > > params[:bus_time][:time] = Date.parse(params[:bus_time][:time]) > > The above code will ensure that the appropriate Date is created from the > input time (appending today''s date to it). > > Secondly you need to get your query back to how it was with *Time.now* > being > used instead of what I had changed it to. > > But in your view you should be doing @bus_time.time.strftime(''%H:%M:%S'') > if > @bus_time.time. > That should output 00:00:00 appropriately when it is that. > > Thanks & Regards, > Dhruva Sagar. > > > > > On Thu, Dec 3, 2009 at 4:30 PM, Terry6004 <nish.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: > >> >> >> >> Terry6004 wrote: >> > >> > Hi Mr Sagar, >> > >> > I ran that query in my console and it returned an array of times etc so >> i >> > will post one line to you which is: >> > >> > #<BusTime id: 97, weekday: "thursday", time: "2000-01-01 11:29:00", >> > created_at: nil, updated_at: nil> >> > >> > Please note that the time attribute is time:time not datetime but rails >> > still gives me 2000-01-01 for some reason >> > >> > >> > Dhruva Sagar wrote: >> >> >> >> 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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> >> 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.patel-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> >> >>> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> >>> >> To unsubscribe from this group, send email to >> >>> >> >> >>> >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> > >> >>> >> <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> <rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%25252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> > >> >>> > >> >>> >> . >> >>> >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> >>> > To unsubscribe from this group, send email to >> >>> > >> >>> >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> > >> >>> . >> >>> > 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org >> . >> >>> To unsubscribe from this group, send email to >> >>> >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> > >> >>> . >> >>> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> >> To unsubscribe from this group, send email to >> >> >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> >> 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-tp26622148p26624172.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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-tp26622148p26626913.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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
ok iam wory ther is my world very polici On Thu, Dec 3, 2009 at 4:44 AM, -روشنک <maryam.kamali.iran-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> good taime iam maryam my phone has danger there is iran i not wey > > On Dec 3, 2:11 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > 2009/12/3 Terry6004 <nish.pa...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>: > > > > > > > > > > > > > Terry6004 wrote: > > > > >> Hi Mr Sagar, > > > > >> I ran that query in my console and it returned an array of times etc > so i > > >> will post one line to you which is: > > > > >> #<BusTime id: 97, weekday: "thursday", time: "2000-01-01 11:29:00", > > >> created_at: nil, updated_at: nil> > > > > >> Please note that the time attribute is time:time not datetime but > rails > > >> still gives me 2000-01-01 for some reason > > > > There is no time of day class in ruby, the Time class (confusingly) > > includes the date, which seems to be set to 2000-01-01 if only a time > > of day is provided. Either you must cope with this in your > > application or you must store the time of day in some other form such > > as integer seconds into the day or as a string for example. > > > > Colin > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.