# Inflections

**URL:** <https://www.ruby-forum.com/t/inflections/150398>\
**Category:** Rails\
**Created:** [October 8, 2008, 2:52am UTC](https://www.ruby-forum.com/t/inflections/150398 "2008-10-08T02:52:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stuart.coyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9d8465/32.png) [@stuart.coyle](https://www.ruby-forum.com/u/stuart.coyle)\
**Post date:** [October 8, 2008, 2:52am UTC](https://www.ruby-forum.com/t/inflections/150398/1 "2008-10-08T02:52:32Z")

</div>

I’m having difficulty getting inflections to work properly.  
I have put this into environment inflection.rb :

ActiveSupport::Inflector.inflections do |inflect|  
inflect.plural ‘criterion’, ‘criteria’  
inflect.singular ‘criteria’, ‘criterion’  
end

I have a habtm relationship between component\_types and criteria with  
tables called  
component\_types, criteria and the join table component\_types\_criteria

But when I do this…

> > c = Criterion.new  
> > =\> #\<Criterion id: nil, question: nil, notes: nil, result\_type\_id:  
> > nil, created\_at: nil, updated\_at: nil\>
> 
> > c.save  
> > =\> true
> 
> > d = ComponentType.new  
> > =\> #\<ComponentType id: nil, name: nil, manufacturer: nil, description:  
> > nil, created\_at: nil, updated\_at: nil\>
> 
> > d.save  
> > =\> true
> 
> > d.criteria \<\< c  
> > NameError: uninitialized constant ComponentType::Criterium  
> > from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/  
> > active\_support/dependencies.rb:493:in `const_missing' from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.1/lib/active_record/ base.rb:1914:in`compute\_type’  
> > from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.1/lib/active\_record/  
> > reflection.rb:129:in `send' from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.1/lib/active_record/ reflection.rb:129:in`klass’  
> > from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.1/lib/active\_record/  
> > reflection.rb:137:in `quoted_table_name' from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.1/lib/active_record/ associations/has_and_belongs_to_many_association.rb:80:in`construct\_sql’  
> > from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.1/lib/active\_record/  
> > associations/association\_collection.rb:8:in `initialize' from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.1/lib/active_record/ associations.rb:1135:in`new’  
> > from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.1/lib/active\_record/  
> > associations.rb:1135:in `criteria’  
> > from (irb):8
> 
> >

I get a NameError, apparently ActiveRecord is looking for the singular  
of criteria which it thinks is criterium. Active Record is bad at  
latin, methinks.

Any clues? Or do I just have to refactor and rename the Criterion  
model to Criterium?

---

<div class="post-metadata">

**Author:** ![stuart.coyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9d8465/32.png) [@stuart.coyle](https://www.ruby-forum.com/u/stuart.coyle)\
**Post date:** [October 8, 2008, 3:08am UTC](https://www.ruby-forum.com/t/inflections/150398/2 "2008-10-08T03:08:56Z")

</div>

And I solved it myself…  
I have to put the capitalized versions of the words in the  
inflections, or rather make them a case insensitive regex!

Apologies for the noise.
