2016-09-26 67 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