Hello, I have a strange behavior and don't know why.
If I override attributes from AcitveRecord object like below:
def end_date=(date)
date = date.to_date unless date.blank?
write_attribute(:end_date,date)
end
def end_date
date = read_attribute(:end_date)
I18n.localize(date) if date.present?
end
Everything will work fine but when I try call text_field in a form_for
block I get the database value and ignore end_date getter.
<%= f.text_field :end_date, :class=>"date", :size=>"10" %>
The text_field will be filled with 2008-12-10 (mysql date) instead of
10/12/2008 ( I18n localized)
Anyone know why we get this behavior?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---