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 <[email protected]> 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 [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<rubyonrails-talk%[email protected]> >> . >> 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

