Forum: Ruby on Rails Singularize Pluralize "tax"

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D8bdf72ae5ca202c0997ac3a04b1bf5f?d=identicon&s=25 thoughtobject@gmail.com (Guest)
on 2007-03-12 19:30
(Received via mailing list)
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?
6d3c187a8b3ef53b08e3e7e8572c4fea?d=identicon&s=25 Jeremy McAnally (Guest)
on 2007-03-12 19:37
(Received via mailing list)
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@gmail.com <thoughtobject@gmail.com> wrote:
> When I open up the console I see that:
> >
>


--
http://www.jeremymcanally.com/

My free Ruby e-book:
http://www.humblelittlerubybook.com/book/

My blogs:
http://www.mrneighborly.com/
http://www.rubyinpractice.com/
588ab1c0a5610a7e160a3b101abb91e6?d=identicon&s=25 MichaelLatta (Guest)
on 2007-03-12 19:52
(Received via mailing list)
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...@gmail.com"
This topic is locked and can not be replied to.