This project is archived and is in readonly mode.

#3362 ✓stale
cmilfont

Fix inflection in reflection

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

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!

Comments and changes to this ticket

  • Rohit Arondekar

    Rohit Arondekar October 6th, 2010 @ 06:38 AM

    • 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.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages