2016-09-26 92 views
0

我刚从Rails迁移中创建了两个表。一个用于ShippingLabel,另一个用于名为Shippo的型号。迁移成功运行,它在Postgres中正确创建了一个表格,它甚至看起来像将Shippo视为一个常量。然而,它不像它应该为Shippo那样继承自ActiveRecord :: Base。Rails模型不能继承ActiveRecord :: Base

shippo.rb

class Shippo < ActiveRecord::Base 
end 

shipping_label.rb

class ShippingLabel < ActiveRecord::Base 

    belongs_to :device_purchase 

end 

当我运行ShippingLabel < ActiveRecord::Base我得到true。当我在控制台中运行Shippo < ActiveRecord::Base时,我得到nil

+0

表名是'shippos'和Postgres的 –

+0

'shipping_labels'尝试重新加载你的Rails控制台。 – Ilya

+0

@llya我试过'重新加载!'并退出它多次,没有运气 –

回答

0

我通常在对象的实例上使用class.superclass来确定超类。

在Rails控制台:

shippo = Shippo.new #shippo is an instance of the class Shippo 
shippo.class.superclass