Upgrading my application - 2.3.5 to 3.2

Hello everybody...

i was trying update my application from 2.3.5 (yes... i know, very old) to 3.2.

as we know, many changes occurred during that time and i don't know if this ploblem is a know problem or other rule of pluralization... well i really don't know how to solve this.

two models

Class Department < ActiveRecord::Base   ...   has_many :waves   ... end

Class Wave < ActiveRecord::Base   ...   belongs_to :department   ... end

Department.find(x).waves

explode this...

uninitialized constant Department::Wafe

/Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/gems/ activerecord-3.2.0/lib/active_record/inheritance.rb:119:in `compute_type'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/activerecord-3.2.0/lib/active_record/reflection.rb:172:in `klass'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/activerecord-3.2.0/lib/active_record/associations/association.rb: 117:in `klass'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/activerecord-3.2.0/lib/active_record/associations/association.rb: 165:in `find_target?'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/activerecord-3.2.0/lib/active_record/associations/ collection_association.rb:332:in `load_target'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/activerecord-3.2.0/lib/active_record/associations/ collection_proxy.rb:44:in `load_target'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/activerecord-3.2.0/lib/active_record/associations/ collection_proxy.rb:88:in `method_missing'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/hirb-0.6.0/lib/hirb/formatter.rb:87:in `block in determine_output_class'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/hirb-0.6.0/lib/hirb/formatter.rb:87:in `each'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/hirb-0.6.0/lib/hirb/formatter.rb:87:in `any?'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/hirb-0.6.0/lib/hirb/formatter.rb:87:in `determine_output_class'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/hirb-0.6.0/lib/hirb/formatter.rb:53:in `format_output'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/hirb-0.6.0/lib/hirb/view.rb:204:in `render_output'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/hirb-0.6.0/lib/hirb/view.rb:123:in `view_output'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/hirb-0.6.0/lib/hirb/view.rb:200:in `view_or_page_output'     /Users/murilomonteiro/.rvm/gems/ruby-1.9.3-p0@TalentTracker3.2/ gems/hirb-0.6.0/lib/hirb/view.rb:186:in `output_value'     /Users/murilomonteiro/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/ irb.rb:160:in `block (2 levels) in eval_input'     /Users/murilomonteiro/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/ irb.rb:273:in `signal_status'     /Users/murilomonteiro/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/ irb.rb:156:in `block in eval_input'     /Users/murilomonteiro/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/ ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'     /Users/murilomonteiro/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/ ruby-lex.rb:229:in `loop'     /Users/murilomonteiro/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/ ruby-lex.rb:229:in `block in each_top_level_statement'     /Users/murilomonteiro/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/ ruby-lex.rb:228:in `catch'     /Users/murilomonteiro/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/ ruby-lex.rb:228:in `each_top_level_statement'     /Users/murilomonteiro/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/ irb.rb:155:in `eval_input'     /Users/murilomonteiro/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/ irb.rb:70:in `block in start'

i can find Wave.find(x).department.

why of this? uninitialized constant Department::Wafe

Thanks in advance for answers...

I think the inflection rules changed somewhere around 3.0, so when rails tries to depluralize :waves, it gets 'wafe' and so looks for a class of that name.

You should be able to override that inflection rule by doing something like

ActiveSupport::Inflector.inflections do |inflect|    inflect.irregular 'wave', 'waves' end

in an initializer

Fred

i can find Wave.find(x).department.

why of this? uninitialized constant Department::Wafe

I think the inflection rules changed somewhere around 3.0, so when

rails tries to depluralize :waves, it gets ‘wafe’ and so looks for a

class of that name.

You should be able to override that inflection rule by doing something

like

ActiveSupport::Inflector.inflections do |inflect|

inflect.irregular ‘wave’, ‘waves’

end

in an initializer

To add more to what Fred said, you should already have an initializer which is specifically for this purpose, look for config/initializers/inflections.rb file

Chirag http://sumeruonrails.com

Root cause is probably related to:

1.9.3p0 :002 > “Waves”.singularize => “Wafe”

Fix that first in config/initializers/inflections.rb

When the problem persists, we can look further.

HTH,

Peter

Thanks Fred, Chirag and Peter.

I wrote the following code inside the inflections:

ActiveSupport::Inflector.

inflections do |inflect|

inflect.irregular ‘wave’, ‘waves’

end

and “waves”.singularize return “waves”

this was the cause of the problem.

Thnks again.