I’m looking for a clean solution to convert Date and DateTime values to local persian date representation in get operations, and whenever a form posted containing persian date values convert it back to Date and DateTime.
The solution in ASP.NET MVC is easy and I’ve implemented it in past.
Now I’m looking for Rails equivalent mechanism.
You can see what I’ve tried so far here(1,
2, 3) but it’s not clean plus that I faced problem traversing association in activerecord because attributes just return the simple members not associations.
Environment:
Ruby version 1.9.3-p327 (x86_64-darwin12.2.0)
RubyGems version 1.8.24
Rails version 3.2.9
I found a gem named attribute_normalizer which would be very helpful though that I write my little code block as this in ApplicationHelper and set it as before_filter in controller.
This is a method for converting dates to different formats:
https://github.com/jzinedine/leasing/blob/e495d652f025c344c49dc079f6826e045f6c986b/app/helpers/application_helper.rb