Nicolas Blanco wrote:
I'm using custom read and write accessors in my models like :
class Order < ActiveRecord::Base
My problem is that Form helpers like text_field, text_area, etc, don't seem to work with these custom accessors, is that normal ?
In order to preserve both database field formats and redisplayed
user input, AR form helpers get their display strings from
So you could write:
But if you want a common date display format throughout your app,
ActiveSupport::CoreExtensions::Conversions::DATE_FORMATS[:default] = '%d/%m/%Y'
to environment.rb, and write in your model
You'll also need a setter
self[:date] = val.is_a?(String) ? val.to_date : val
plus, since Rails does not currently support non-US formats for
string-to-date conversions, you'll have to add this to environment.rb