thoughtobject-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-12 18:29 UTC
Singularize Pluralize "tax"
I have a table: municipal_taxes and a model: MunicipalTax which belongs_to :company Company has_many :municipal_taxes I get this error: NameError: uninitialized constant Company::MunicipalTaxis from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/ active_support/dependencies.rb:477:in `const_missing'' When I open up the console I see that: "tax".pluralize # => "taxes" "taxes".singularize # => "taxis" "taxis".pluralize # => "taxes" "taxis".singularize # => "taxi" I corrected this with the Inflector in environment.rb but why might this be happening? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The inflector isn''t perfect; a few attempts have been made to add a few things, but the typical response is deal with it in environment.rb. It''s getting "taxes" => "taxis" from the regex that says "axes" => "axis." You did the right thing (in the Rails core team''s opinion) by addressing it in environment.rb. :) --Jeremy On 3/12/07, thoughtobject-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <thoughtobject-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have a table: municipal_taxes and a model: MunicipalTax > which belongs_to :company > Company has_many :municipal_taxes > > I get this error: > NameError: uninitialized constant Company::MunicipalTaxis > from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/ > active_support/dependencies.rb:477:in `const_missing'' > > When I open up the console I see that: > > "tax".pluralize # => "taxes" > "taxes".singularize # => "taxis" > "taxis".pluralize # => "taxes" > "taxis".singularize # => "taxi" > > I corrected this with the Inflector in environment.rb but why might > this be happening? > > > > >-- http://www.jeremymcanally.com/ My free Ruby e-book: http://www.humblelittlerubybook.com/book/ My blogs: http://www.mrneighborly.com/ http://www.rubyinpractice.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
As a workaround you can always use the :class_name and :foreign_key options also to override the default naming. Michael On Mar 12, 11:29 am, "thoughtobj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <thoughtobj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a table: municipal_taxes and a model: MunicipalTax > which belongs_to :company > Company has_many :municipal_taxes > > I get this error: > NameError: uninitialized constant Company::MunicipalTaxis > from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/ > active_support/dependencies.rb:477:in `const_missing'' > > When I open up the console I see that: > > "tax".pluralize # => "taxes" > "taxes".singularize # => "taxis" > "taxis".pluralize # => "taxes" > "taxis".singularize # => "taxi" > > I corrected this with the Inflector in environment.rb but why might > this be happening?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---