Hi,
I have a date string: "2009-10-12". I would like to write a method that takes this as a parameter and returns the three lettered day of the week (in this case 'mon'). I wrote this:
def date_to_day_of_week(date)
d = Date.parse(date).strftime("%a").downcase!
return d
end
When I call this from script/console, it works as expected. However, when I call this from within my app I get a variety of different errors depending on what I do. The main problems are that either date_to_day_of_week
is an undefined method, or if I move the contents of the method (i.e. day = Date.parse(date).strftime("%a").downcase!
inline, then I get private method gsub! called for Mon, 12 Oct 2009:Date
. I just think I'm starting to understand Ruby and Rails and then I get thrown back to the start!
Can anyone help with this?
Gav