In Ruby on Rails 3 I'm trying to modify my Model dataset's dates to only show hours and minutes, which I then return as an AJAX string.
My code is the following:
list_of_time_fields = [:a, :list, :of, :symbols]
result = Model.where(conditions).take(100)
result.each { |row|
list_of_time_fields.each { |field|
row[field] = row[field].strftime("%H:%M") unless row[field].nil?
}
}
return result
For some fields I get the whole time string (something like yyyy-mm-ddTHH:MM:ssZ) and for others I get nulleven if the field is not null. The difference is that the ones that return strings are TIME fields in MySQL, whereas the others are DATETIME.
I've checked the types to which Rails maps these columns and everything is class Time.
If you can point which things I should look at It'd be great.