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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -