Problem solved thank you for your help I appreciated instead of all i called :first it was listing an array thats all thanks
Dhruva Sagar wrote: > > The error implies that the find returned no records and you were trying to > access it in the view to display it perhaps ? > > Try the following : > > @bus_time = BusTime.find(:first, :order => "weekday", :conditions => > ["time > ? AND weekday = ?", Time.now, Date::DAYNAMES[Date.today.wday]]) > > If it still gives you the same error, please look at the logs and check > the > SQL query running in the background, if it's returning no records see > what's > wrong in the query / database. > > Thanks & Regards, > Dhruva Sagar. > > > > > On Wed, Dec 2, 2009 at 3:26 PM, Terry6004 <nish.pa...@hotmail.com> wrote: > >> >> Hi Dhruva, >> >> I tried this and get: No method error You have a nil object when you >> didn't >> expect it! >> The error occurred while evaluating nil.weekday >> >> I would also like to point out that in my def show I have the following: >> >> @bus_time = BusTime.find(:first, :order => "weekday", :conditions => >> ["time >> > ?", Time.now]) >> >> This helps me to get all the next available times on that day, can you >> see >> what I am trying to do, I am trying to get the latest times available for >> a >> bus on a particular day because sunday's times are different please could >> you help thanks for the very quick reply >> >> >> >> >> Dhruva Sagar wrote: >> > >> > I can give you an example, you would have to improvise on the same >> > according >> > to your needs. >> > >> > @bus_times = BusTime.find(:all, :conditions => ['weekday = >> > ?', Date::DAYNAMES[Date.today.wday]]) >> > >> > The above would give you all the bus_time records where weekday equals >> > todays day... >> > Hope it helps. >> > >> > Thanks & Regards, >> > Dhruva Sagar. >> > >> > >> > >> > >> > On Wed, Dec 2, 2009 at 3:01 PM, Terry6004 <nish.pa...@hotmail.com> >> wrote: >> > >> >> >> >> Hi all, I am a newbie and just recently started to create apps with >> ruby >> >> on >> >> rails so please go easy on me :) >> >> >> >> I have an app which has a database in mysql which is called bus_times >> and >> >> consists of 3 columns which are: id, time and weekday. Time is set to >> >> time >> >> and weekday is a string. So it looks something like this: >> >> >> >> 1 monday 20:00:00 >> >> 2 tuesday 12:00:00 >> >> 3 wednesday 3:00:00 >> >> 4 wednesday 15:00:00 ..etc >> >> >> >> What I want to do is to pick out the times from my database and show >> them >> >> on >> >> my view depending on what the date is today. Hence assign my strings >> >> mon,tues,wed etc to an actual date so like today is wednesday I want >> it >> >> to >> >> pick out just the wednesday times. How do I do this I have looked >> >> everywhere >> >> and cannot find a solution thanks in advance... >> >> -- >> >> View this message in context: >> >> >> http://old.nabble.com/What-if-statements-help-with-dates-tp26605994p26605994.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/What-if-statements-help-with-dates-tp26605994p26606358.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. > > > > -- View this message in context: http://old.nabble.com/What-if-statements-help-with-dates-tp26605994p26607233.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. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.