所以我看到这个奇怪的错误,当我尝试做一个相当简单的交互式测试我添加的关联。这里有两种型号:测试协会撬奇怪的错误
class Lot < ActiveRecord::Base
has_many :graves
belongs_to :block
end
class Grave < ActiveRecord::Base
belongs_to :lot
end
下面是创建表的迁移:
class CreateGraves < ActiveRecord::Migration
def change
create_table :graves do |t|
t.integer :grave_number
t.integer :lot_id
t.timestamps null: false
end
end
end
class CreateLots < ActiveRecord::Migration
def change
create_table :lots do |t|
t.integer :lot_number
t.integer :map_type
t.timestamps null: false
end
end
end
我调用撬带:
pry -r ./config/environment.rb
然后在撬会议上,我简单地做:
lot = Lot.new
l.graves
我得到这个错误:
NameError: uninitialized constant Lot::Grafe
from /.../activerecord-4.2.6/lib/active_record/inheritance.rb:158:in `compute_type'
...有简单的路径,我的rbenv安装和红宝石2.3.0子目录链。我在那里替换它以保持输出可读。
我还有其他类定义了其他类似的关联,所有这些都按预期工作。
改变从'类名后的默认行为坟墓'到'Gravesite'照顾这个。我不知道系统中的什么宝石会干扰Grave类的名称,但是无论它是哪一个,它都是一个巨大而嘈杂的WTF。 – jaydel