Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

simple_form missing translation

I have a date attribute of Date type.

= f.input :date

And simple_form raises an exception:

undefined method `map' for "translation missing: fr.date.order":String

I am not supposed to do anything by default. Translations should be okay. I have no clue what I should look for.

The full code view:

section
  .row
    h1= t('actions.new')

  .row
    = simple_form_for @group_action, url: admin_actions_path do |f|
      = f.input :concerned_object
      = f.input :concerned_company
      = f.input :date
      = f.input :amount_estimation
      = f.input :description
      = f.input :tags

      = f.button :submit

The group_action schema:

  create_table "group_actions", force: true do |t|
    t.integer  "user_id",                        null: false
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "concerned_object",  default: "", null: false
    t.string   "concerned_company", default: "", null: false
    t.date     "date",                           null: false
    t.string   "amount_estimation", default: "", null: false
    t.text     "description",       default: "", null: false
    t.string   "tags"
  end

The model:

class GroupAction < ActiveRecord::Base
  belongs_to :lawyer, class_name: User, foreign_key: 'user_id'
end

A colleague proposed me to use order option as a workaround:

= f.input :date, order: [:day, :month, :year]

This gets rid of the exception but I'm still having trouble with default translations. On the image below, it's the select element where are supposed to be listed the months.

enter image description here

like image 587
Adrien Avatar asked Feb 02 '26 04:02

Adrien


1 Answers

If you use a different locale than :en, you have to install rails-i18n gem.

like image 153
Adrien Avatar answered Feb 04 '26 18:02

Adrien



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!