Change datetime to simple %m/%d/%Y in database with rails -


i have field called :date :datetime. trying save huge datetime string simple mm/dd/yyyy in database, not having luck. have tried 'american_date' gem, , have tried separate call in model here:

after_save :change_date  def change_date     self.date.strftime("%m/%d/%y") end 

none of these have worked though. help? stack!

try this:

add file config/initializers following code:

date::date_formats[:default]="%m/%d/%y" time::date_formats[:default]="%m/%d/%y %h:%m" time::date_formats[:db]="%m/%d/%y" 

and see railcast.


Comments

Popular posts from this blog

ios - Memory not freeing up after popping viewcontroller using ARC -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -