Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Fix inflection in reflection

#3362

Hello guys, i am suggesting this patch to resolve a problem the inflector in my language in relations has_many.
We have grammar rules that singularize the first word in compounds words

See how is the singular and plural in my idiom
ActiveSupport::Inflector.inflections do |inflect|

inflect.irregular 'plano_de_contas_base', 'planos_de_contas_base'
inflect.irregular 'plano_de_contas', 'planos_de_contas'

end

I found this solution to singularize correctly

class_name = name.to_s.camelize
output PlanosDeContas

class_name.singularize
output PlanosDeConta

name.to_s.singularize.camelize
output PlanoDeContas, it should be done

has_many example

book-keeper in portuguese
class PlanoDeContas < ActiveRecord::Base

belongs_to :banco

end

bank in portuguese
class Banco < ActiveRecord::Base

has_many :planos_de_contas

end

cheers!

Reported by cmilfont · October 9th, 2009 @ 08:05 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to stale
    • Importance changed from to

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

    October 6th, 2010 @ 06:38 AM