the goob
2007-Jan-21  07:04 UTC
Funny singularization/constantization in scaffold controller
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
--~--~---------~--~----~------------~-------~--~----~
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 goob
2007-Jan-21  07:14 UTC
Re: Funny singularization/constantization in scaffold controller
Hmmm. Maybe in environment.rb an inflection rule? Sorry, should have looked a little farther before posting. --~--~---------~--~----~------------~-------~--~----~ 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 goob
2007-Jan-21  07:31 UTC
Re: Funny singularization/constantization in scaffold controller
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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
askegg
2007-Jan-21  20:27 UTC
Re: Funny singularization/constantization in scaffold controller
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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Phlip
2007-Jan-21  21:16 UTC
Re: Funny singularization/constantization in scaffold controller
askegg wrote:> Inflector.inflections do |inflect| > inflect.irregular ''genus'', ''genera'' > endCan''t you just require ''latin'' ? <a pause> Ouch! Don''t hit! Don''t hit!! -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jeffrey Mills
2007-Jan-30  03:17 UTC
Re: Funny singularization/constantization in scaffold controller
Ha require ''little_latin'' require ''less_greek'' whatever works this got caught by my spam filter so a slow reply. take care On Jan 21, 2007, at 1:16 PM, Phlip wrote:> > askegg wrote: > >> Inflector.inflections do |inflect| >> inflect.irregular ''genus'', ''genera'' >> end > > Can''t you just > > require ''latin'' > > ? > > <a pause> > > Ouch! Don''t hit! Don''t hit!! > > -- > Phlip > http://www.greencheese.us/ZeekLand <-- NOT a blog!!! > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---