Differences in execution between console and app

You can't create a Range over 2 Dates and iterate over those - I'm assuming that's what you want to do.

but what you can do is iterate over the lookahead

(0..look_ahead).each do |diff|   yield (date+diff.....) end

ok i seems you sometimes CAN create ranges of dates - but that it doesn't work in a running app points towards some strange view-helpers being added to the date-class or something like that. my method should still work, while yours implies some kind of hidden to_i/to_date back-and-forth which could lead to that error. don't try to force it if there is another way.

Phil

You can't create a Range over 2 Dates and iterate over those - I'm assuming that's what you want to do.

but what you can do is iterate over the lookahead

(0..look_ahead).each do |diff|   yield (date+diff.....) end

I think we've gotten a little off-track. Allow me to steer us back in the right direction...

This is the line throwing the error in my app:

appointments.find_all_by_date(date)

What's the stack trace of the error?

Fred

ah .. yes sorry I seem to be responding while new and clarifying messages are added to this thread.. that way I got off-track.

have you tried converting the date to a string before the find_all_by_date() ? or formulating it as a :conditions array ?

these are not solutions but you could analyse the problem from different angles like that.

P

Oh, yeah, weird. I would just change it to appointments.find_all_by_date Date.today.to_s(:db)

and cross my fingers.

Pat

What database are you using? Version, and adapter version? It looks like AR isn't treating something as a date there. Like it's sanitizing the SQL as a string...which most likely means (to me) that for some reason it doesn't know that the db column is a date. Did you perhaps mess up on the migration and create the date field as a string instead of a date?

Pat

Pat Maddox wrote:

Oh, yeah, weird. I would just change it to appointments.find_all_by_date Date.today.to_s(:db)

and cross my fingers.

Pat

What does the (:db) to?

ActiveSupport overrides Date#to_s, passing :db makes it format the
string in the way the database wants it. Fred