Hi, i think i might have stumbled upon a bug.
I have the following field declaration on a simple_form:
<%= f.input :start_date %>
My application is internationalized and i'm getting the following error in that line while rendering the template:
undefined method `-' for "translation missing: en.date.order":String
The last lines of the stack trace are the following:
actionpack (3.1.0) lib/action_view/helpers/date_helper.rb:651:in select_datetime'
actionpack (3.1.0) lib/action_view/helpers/date_helper.rb:979:into_datetime_select_tag'
actionpack (3.1.0) lib/action_view/helpers/date_helper.rb:290:in datetime_select'
actionpack (3.1.0) lib/action_view/helpers/date_helper.rb:1035:indatetime_select'
simple_form (1.5.1) lib/simple_form/inputs/date_time_input.rb:5:in input'
simple_form (1.5.1) lib/simple_form/components/label_input.rb:11:inlabel_input'
simple_form (1.5.1) lib/simple_form/inputs/base.rb:68:in block in render'
simple_form (1.5.1) lib/simple_form/inputs/base.rb:66:ineach'
simple_form (1.5.1) lib/simple_form/inputs/base.rb:66:in render'
simple_form (1.5.1) lib/simple_form/form_builder.rb:95:ininput'
app/views/jump_events/_form.html.erb:12:in `block in _app_views_jump_events__form_html_erb__3886609086613822031_70186987996920'
Can you guys give me a hand in figuring out what might be wrong? :) Thanks a lot
I don't know if this bug is a SimpleForm fault. Could you try to use the datetime_select helper from Rails and see if your code works?
It is not a SimpleForm bug. This is a Rails bug and is happening because you don't have en.date.order defined in your YAML files.
Sorry about that ... actually i was stupidly overriding the "date" key in my translation file :)
@nocivus : Could you please brief on that error.. because even am facing the same issue and dont know how to solve as am new to rails..
thanks in advance
It's a bit outdated but i had the same problem and i've found a solution. Maybe someone who will be googling for this error will find this thread. Here is my solution:
I was using custom locale file (pl.yml in my case) and all i needed to do was to add those lines in it:
pl:
(...)
date:
order:
- :day
- :month
- :year
(...)
Good luck !
@mbajur thnx man! was usefull!
@mbajur that also worked for me. Thanks!
You can try to use
gem 'rails-i18n'
In your Gemfile
@dix-icomys This work for me
the best and easier way was the gem 'rails-i18n'
passing an option like order: [:year] will resolve this issue if you don't want to put in locale file
@dix-icomys it worked :dancers:
@dix-icomys 馃憤
@mbajur - thank you (although you are promoting the incorrect order for ":pl" :-)
I had also problem with 'month' drop-down control. It was showing some text not months numbers or names and fix in my case for Bosnian bs_BA localization was:
date:
order: [ !ruby/symbol day, !ruby/symbol month, !ruby/symbol year ]
formats:
default: "%Y-%m-%d"
short: "%b %d"
long: "%B %d, %Y"
day_names: [Ponedjeljak, Utorak, Srijeda, Cetvrtak, Petak, Subota, Nedjelja]
#abbr_day_names: [P, U, S, C, Pt, S, N]
month_names: [~, Januar, Februar, Mart, April, Maj, Juni, Juli, August, Septembar, Oktobar, Novembar, Decembar]
#abbr_month_names: [~, Jan, Feb, Mar, Apr, Maj, Jun, Jul, Aug, Sep, Okt, Nov, Dec]
Most helpful comment
You can try to use
In your Gemfile