I have googled a lot on this subject but have not found an easy way to have RoR accept european date format (DD/MM/YYYY) in forms. I looked at globalize plugin but that feels heavy implementation for me because I do not need translations.
bitterbal wrote:
I have googled a lot on this subject but have not found an easy way to have RoR accept european date format (DD/MM/YYYY) in forms. I looked at globalize plugin but that feels heavy implementation for me because I do not need translations.
>
You can replace ParseDate.parsedate function which Rails use to parse dates. Find article with implementation on my blog: http://source.mihelac.org/articles/2006/09/13/parsing-european-date-format-in-ruby-rails
best regards, Bojan
Hello,
I have googled a lot on this subject but have not found an easy way to have RoR accept european date format (DD/MM/YYYY) in forms. I looked at globalize plugin but that feels heavy implementation for me because I do not need translations.
I'm not sure if this helps you, but you can define your own data formats in environment.rb. For example:
ActiveSupport::CoreExtensions::Conversions::DATE_FORMATS.merge!(
:uk_full => '%e %B %Y'
)
And then use the symbolic form with Date.to_s. E.g. in a view:
<%= @order.created_at.to_s :uk_full %>
Regards, Andy Stewart