2016-09-26 1 views
0

방금 ​​레일스 마이그레이션에서 두 개의 테이블을 만들었습니다. 하나는 ShippingLabel이고 다른 하나는 Shippo이라는 모델입니다. 마이그레이션이 성공적으로 실행되고, Postgres에 테이블이 올바르게 생성되며 Shippo를 상수로 인식하는 것처럼 보입니다. 그러나 ActiveRecord :: Base에서 상속받지 않는 것은 Shippo에 적합합니다.레일 모델이 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'와 포스트 그레스 –

+0

에서'shipping_labels'은 레일 콘솔을 다시로드하려고합니다. – Ilya

+0

@llya'reload! '를 시도해 보았습니다. 여러 번 빠져 나오면 안됩니다. –

답변

0

나는 대개 객체의 인스턴스에서 class.superclass를 사용하여 수퍼 클래스를 결정합니다.

에서 레일 콘솔 :

shippo = Shippo.new #shippo is an instance of the class Shippo 
shippo.class.superclass 
관련 문제