I have a Ruby on Rails project that has been untouched for a while, and I'm in the process of trying to upgrade it from Rails 2.0 to 3.1.
I'm getting an error when I try and instantiate one of the models. It seems as though one of the models is also defined somewhere as a module, and this is stopping me from instantiating it.
dgs@dgs-desktop ~/code/spelling $ rails c
Loading development environment (Rails 3.1.1)
ree-1.8.7-head :001 > Spelling.first
NoMethodError: undefined method `first' for Spelling:Module
from (irb):1
ree-1.8.7-head :002 > exit
The spelling class is very basic:
class Spelling < ActiveRecord::Base
belongs_to :word, :class_name => 'Word', :foreign_key => 'word_id'
end
I can't find where in the app (which is pretty small) this module would be defined:
dgs@dgs-desktop ~/code/spelling $ cd app
dgs@dgs-desktop ~/code/spelling/app $ grep Spelling * -R
models/spelling.rb:class Spelling < ActiveRecord::Base
models/word.rb: has_many :spellings, :class_name => 'Spelling', :foreign_key => 'word_id'
models/spelling_user.rb:class SpellingUser < ActiveRecord::Base
views/layouts/application.html.erb: <title> School Spelling Tests</title>
dgs@dgs-desktop ~/code/spelling/app $ find ./ -name "spelling*"
./views/spellings
./views/admin/spellings
./models/spelling.rb
./models/spelling_user.rb
Does anyone know what could be causing this? Or how else I could track down where this module is being defined?
__file__
or source_location, http://stackoverflow.com/questions/175655/how-to-find-where-a-method-is-defined-at-runtime, it didn't work for me, but I have 1.8.7 – ez. Jan 24 '12 at 23:20