Pluralization issue? (taxes/taxis)

Hi all,

Here’s an odd one. I have a “Tax” model which is related via a habtm
relationship to a “Storefront” model. In my view_store rhtml file, I
have the line :

@storefront.taxes.each do |tax|

This line returns the following error:

NameError in Admin#view_store

Showing app/views/admin/view_store.rhtml where line #52 raised:

uninitialized constant Taxis

See that? “Taxes” has become “Taxis”. Since I am not trying to attach a
Yellow Cab to my customers’ orders, I don’t want that. A search of the
whole Rails app turns up no instances of the string “taxi” anywhere.
Therefore I suspect an oddball pluralization.

From the console, “taxi”.pluralize returns “taxis”, and “tax”.pluralize
returns “taxes”, so they look right. Just to be safe, I redeclared those
plurals explicitly in my environment.rb. Still no dice.

I am at a loss, so I am throwing it out to y’all in the hopes someone
might have stumbled across this issue.

thanks,

Michael.

Solved it!

From the console, “taxi”.pluralize returns “taxis”, and “tax”.pluralize
returns “taxes”, so they look right. Just to be safe, I redeclared those
plurals explicitly in my environment.rb. Still no dice.

Apparently the singular -> plural and plural -> singular conversions are
not the same thing, so adding the singularize directives fixed the
problem:

Inflector.inflections do |inflect|
inflect.plural ‘tax’, ‘taxes’
inflect.plural ‘taxi’, ‘taxis’
inflect.singular ‘taxes’, ‘tax’
inflect.singular ‘taxis’, ‘taxi’
end

Rails must think that “taxi” is the singular of “taxes” by default.

  • mL.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs