Tim W. wrote: > That is why I mentioned it was a hack.. > > I take it there is no way to do it via the to_json method which is the > view at this point?
Given that JSON offers no data type for storing date and time information, a choice must be made. Rails core team, I believe smartly, decided to borrow the string representation of time from XML, which does define standard date and time representations. I would not call this a view. In the same way as databases store representations of the data, so does the serialized string of JSON or XML. What I was getting at in my previous reply was that regardless of how the data is actually stored in a data model (whether that be in model objects, a database or a serialized string) it is still the responsibility of the view layer in MVC to format the data for presentation to the user. Even though the serialized date may be stored as "2009-08-19T13:03:07Z" you probably would not want to present that to the end user. They would probably prefer something based on their own locale. In the US that might be: "August 19, 2009 9:00 AM" or in Europe maybe something like "19 August 2009 09:00." If I'm not mistaken you can use I18n (Internationalization) in Rails to format dates based on the user's locale. Given that JSON (or XML) are not what you present to end users, you would store the date and time in a way meaningful to your model. Only when you present that data to a human do you run the data through formatters for presentation. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

