0
나는 activerecord 모델을 상속 할 수 있었으면 좋겠다. 부모 클래스가 될 수있을만큼 하위 클래스를 사용하고 싶다. 이것은 그럴 듯하지는 않지만 AR 관계는 하위 클래스에서 작동하지 않는 것처럼 보입니다.Ruby on Rails에서 활성 레코드 모델 상속
class Manager < User
belongs_to :shop
end
class Shop < ActiveRecord::Base
has_many :managers
end
class PremiumShop < Shop
end
및
@premium_shop = manager.shop # Finds the shop.
@premium_shop = manager.premium_shop # Does not find the shop, NilClass:Class error
는이 일을 할 수 있습니까?
이 경우 class_name : "PremiumShop"이 필요하지 않다고 생각합니다. 연관 이름': premium_shop'에서 추측 되었습니까? 아니면? – 244an