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?
on 2008-10-08 02:52
on 2008-10-08 03:08
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.