Nested Translation wrong Inflection

Asked

Viewed 97 times

0

Opa,

The problem is this: I have a model called Idea and I’m trying to add a new nested in it to Ideategoria which is an associative with Idea. So we have:

Idea:
has_many :ideia_categories, inverse_of: :idea, dependent: :Destroy
accepts_nested_attributes_for :ideia_categories, :reject_if => :all_blank, :allow_destroy => true

Ideiacategoria:
belongs_to :idea
belongs_to :category

Category:
has_many :ideia_categories, inverse_of: :category, dependent: :Destroy

In my idea form I have like this:
inserir a descrição da imagem aqui

And when I enter this form returns me the error:

inserir a descrição da imagem aqui

And in my inflection is so that part of the ideas:

inflect.plural "ideia_comentario", "ideia_comentarios"
inflect.singular "ideia_comentarios", "ideia_comentario"

inflect.plural "ideia_arquivo", "ideia_arquivos"
inflect.singular "ideia_arquivos", "ideia_arquivo"

inflect.plural "ideia_categoria", "ideia_categorias"
inflect.singular "ideia_categorias", "ideia_categoria"

inflect.plural "categoria", "categorias"
inflect.singular "categorias", "categoria"

Where are you pulling this Ideiacategorium?

1 answer

0

Here’s a hint of how to put in your inflections file:

ActiveSupport::Inflector.inflections do |inflect|
  inflect.clear

  inflect.plural(/$/,  's')
  inflect.plural(/(s)$/i,  '\1')
  inflect.plural(/^(paí)s$/i, '\1ses')
  inflect.plural(/(z|r)$/i, '\1es')
  inflect.plural(/al$/i,  'ais')
  inflect.plural(/el$/i,  'eis')
  inflect.plural(/ol$/i,  'ois')
  inflect.plural(/ul$/i,  'uis')
  inflect.plural(/([^aeou])il$/i,  '\1is')
  inflect.plural(/m$/i,   'ns')
  inflect.plural(/^(japon|escoc|ingl|dinamarqu|fregu|portugu)ês$/i,  '\1eses')
  inflect.plural(/^(|g)ás$/i,  '\1ases')
  inflect.plural(/ão$/i,  'ões')
  inflect.plural(/^(irm|m)ão$/i,  '\1ãos')
  inflect.plural(/^(alem|c|p)ão$/i,  '\1ães')

  # Sem acentos...
  inflect.plural(/ao$/i,  'oes')
  inflect.plural(/mês$/i,  'meses')
  inflect.plural(/^(irm|m)ao$/i,  '\1aos')
  inflect.plural(/^(alem|c|p)ao$/i,  '\1aes')

  inflect.singular(/([^ê])s$/i, '\1')
  inflect.singular(/^(á|gá|paí)s$/i, '\1s')
  inflect.singular(/(r|z)es$/i, '\1')
  inflect.singular(/([^p])ais$/i, '\1al')
  inflect.singular(/eis$/i, 'el')
  inflect.singular(/ois$/i, 'ol')
  inflect.singular(/uis$/i, 'ul')
  inflect.singular(/(r|t|f|v)is$/i, '\1il')
  inflect.singular(/ns$/i, 'm')
  inflect.singular(/sses$/i, 'sse')
  inflect.singular(/^(.*[^s]s)es$/i, '\1')
  inflect.singular(/ães$/i, 'ão')
  inflect.singular(/aes$/i, 'ao')
  inflect.singular(/ãos$/i, 'ão')
  inflect.singular(/aos$/i, 'ao')
  inflect.singular(/ões$/i, 'ão')
  inflect.singular(/oes$/i, 'ao')
  inflect.singular(/(japon|escoc|ingl|dinamarqu|fregu|portugu)eses$/i, '\1ês')
  inflect.singular(/^(g|)ases$/i,  '\1ás')
  inflect.irregular('palavra_chave', 'palavras_chaves')
  inflect.irregular('joao_ninguem', 'jooes_ninguem')
end

The last two lines are in case you want to put plural in the two words as would be the case of the plural of a compound noun.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.