# Funny singularization/constantization in scaffold controller

**URL:** <https://www.ruby-forum.com/t/funny-singularization-constantization-in-scaffold-controller/82809>\
**Category:** Rails\
**Created:** [January 21, 2007, 8:05am UTC](https://www.ruby-forum.com/t/funny-singularization-constantization-in-scaffold-controller/82809 "2007-01-21T08:05:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![the\_goob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@the\_goob](https://www.ruby-forum.com/u/the_goob)\
**Post date:** [January 21, 2007, 8:05am UTC](https://www.ruby-forum.com/t/funny-singularization-constantization-in-scaffold-controller/82809/1 "2007-01-21T08:05:25Z")

</div>

Hi all. I’m new to Ruby and Rails so please bear with. I’m creating  
an app to maintain a birders life list. One of the Models I need is  
Genus. The plural of Genus is Genera. So, my table is titled Genera  
and in my genus.rb I have the line ‘self.table\_name = “genera”’. My  
first hurdle was that when I generate the scaffold it still wanted a  
table called genus. Got around that by creating a view genus as  
suggested somewhere. Now the scaffold (genus\_maint) generates but when  
I try to execute I get a “uninitialized constant Genu” when the list  
method is trying to paginate:

‘@genus\_pages, @genus = paginate :genus, :per\_page =\> 10’

It’s as if rails is trying to singularize “genus”. Actually, what it  
is really trying to do is constantize it.

Here’s the full trace:

/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active\_support/dependencies.rb:123:in  
`const_missing' /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in`const\_missing’  
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active\_support/inflector.rb:161:in  
`constantize' /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/string/inflections.rb:59:in`constantize’  
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/pagination.rb:194:in  
`paginator_and_collection_for' /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:129:in`paginate’  
#{RAILS\_ROOT}/app/controllers/genus\_maint\_controller.rb:12:in `list' #{RAILS_ROOT}/app/controllers/genus_maint_controller.rb:3:in`index’  
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/bin/mongrel\_rails:18

Hope this looks okay. I haven’t tried any formatting on this question.

TIA for any advice.

the goob

---

<div class="post-metadata">

**Author:** ![the\_goob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@the\_goob](https://www.ruby-forum.com/u/the_goob)\
**Post date:** [January 21, 2007, 8:14am UTC](https://www.ruby-forum.com/t/funny-singularization-constantization-in-scaffold-controller/82809/2 "2007-01-21T08:14:26Z")

</div>

Hmmm.  
Maybe in environment.rb an inflection rule?  
Sorry, should have looked a little farther before posting.

---

<div class="post-metadata">

**Author:** ![the\_goob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@the\_goob](https://www.ruby-forum.com/u/the_goob)\
**Post date:** [January 21, 2007, 8:32am UTC](https://www.ruby-forum.com/t/funny-singularization-constantization-in-scaffold-controller/82809/3 "2007-01-21T08:32:27Z")

</div>

Okay. modified environment.rb with:

Inflector.inflections do |inflect|  
inflect.irregular ‘genus’, ‘genera’  
end

regenerated the model (still had to had the self.table\_name = “genera”  
to genus.rb)

regenerated the scaffold and voila

---

<div class="post-metadata">

**Author:** ![the\_goob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@the\_goob](https://www.ruby-forum.com/u/the_goob)\
**Post date:** [January 21, 2007, 9:27pm UTC](https://www.ruby-forum.com/t/funny-singularization-constantization-in-scaffold-controller/82809/4 "2007-01-21T21:27:56Z")

</div>

the goob wrote:

> Hi all. I’m new to Ruby and Rails so please bear with. I’m creating  
> an app to maintain a birders life list. One of the Models I need is  
> Genus. The plural of Genus is Genera.

Rails is not _that_ clever when working out the plural or singular  
versions of names - it makes good guesses though. You will need to  
specify this in your config/environment.rb file:

Inflector.inflections do |inflect|  
inflect.irregular ‘genus’, ‘genera’  
end

---

<div class="post-metadata">

**Author:** ![the\_goob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@the\_goob](https://www.ruby-forum.com/u/the_goob)\
**Post date:** [January 30, 2007, 4:18am UTC](https://www.ruby-forum.com/t/funny-singularization-constantization-in-scaffold-controller/82809/5 "2007-01-30T04:18:44Z")

</div>

Ha

require ‘little\_latin’  
require ‘less\_greek’  
whatever works

this got caught by my spam filter so a slow reply.

take care

---

<div class="post-metadata">

**Author:** ![the\_goob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@the\_goob](https://www.ruby-forum.com/u/the_goob)\
**Post date:** [January 21, 2007, 10:17pm UTC](https://www.ruby-forum.com/t/funny-singularization-constantization-in-scaffold-controller/82809/6 "2007-01-21T22:17:07Z")

</div>

askegg wrote:

> Inflector.inflections do |inflect|  
> inflect.irregular ‘genus’, ‘genera’  
> end

Can’t you just

require ‘latin’

?

 

Ouch! Don’t hit! Don’t hit!!

 

–  
Phlip  
 [Redirecting...](http://www.greencheese.us/ZeekLand) ← NOT a blog!!!
