sql - Formatting a Field Whenever it's Queried -
i have rails app acts back-end iphone app. whenever record, let's call message
, created, format string coming iphone app ruby datetime saved field in database. string converted nsdate on iphone side. problem want convert datetime string can formatted nsdate whenever query sent messages. there simple solution this?
the view idea not bad one, might suggest putting date_string
attribute on message
model this:
class message def date_string date.to_s # or want format end end
then, when render json, include date_string
. don't know you're using render json, i've had pretty great experience rabl.
Comments
Post a Comment