Cokiehh
Cokiehh

Reputation: 63

RubyOnRails - option_groups_from_collection_for_select and translation of content

I have a collection, I am showing to the user. But I need to I18n.translate the :key into a readable text from my de.yml.

competences:
  key:
    compkey001: "Werbung / 360"
    compkey001subkey002: "Klassische Werbung / ATL"
    compkey002: "Strategie"

f.input :competence_id, label: "Kompetenz", :as => :select,
:collection => option_groups_from_collection_for_select(
@competence_kategories, :competence_unterkats, t(:key, 
scope: 'basic_data.competences'), :id, t(:key, 
scope: 'basic_data.competences'))

This is not working. It is giving me an error, something like: t() is not a method.

The below line is working, but showing the keys that are not usable by the user:

f.input :competence_id, label: "Kompetenz", :as => :select, 
:collection => option_groups_from_collection_for_select( 
@competence_kategories, :competence_unterkats, :key, :id, :key)

Displayed will be:

(bold)compkey001
  compkey001subkey001
(bold)compkey002
... etc.

How can I get the translations being displayed in a grouped manner?

Thanks for help!

Upvotes: 1

Views: 111

Answers (0)

Related Questions