我在炼油厂扩展中遇到STI错误。我有两个扩展名:“reservation_items”和“items”
现在我需要表“items”继承“reservation_items”。
我用炼油厂生成器
rails generate refinery:engine reservation_item date_from:date date_to:date people_min:integer people_max:integer price_1:float price_2:float price_3:float type:string --skip-frontend
rails g refinery:engine item item_type:integer
我在预订_items扩展程序中的模型:
module Refinery
module ReservationItems
class ReservationItem extends Refinery::Core::BaseModel
self.abstract_class = true
self.table_name = 'refinery_reservation_items'
attr_accessible :date_from, :date_to, :people_min, :people_max, :price_1, :price_2, :price_3, :type, :position
validates :type, :presence => true, :uniqueness => true
end
end
end
我将“items”扩展模型更改为:
module Refinery
module Items
class Item extends Refinery::ReservationItems::ReservationItem
self.table_name = 'refinery_items'
attr_accessible :item_type, :position
# def title was created automatically because you didn't specify a string field
# when you ran the refinery:engine generator. Refinery CMS.
def title
"Override def title in vendor/extensions/items/app/models/refinery/items/item.rb"
end
end
end
end
我也试过了:
module Refinery
module Items
class Item extends ReservationItem
我不知道自己的坏事。我如何继承这两个表?
//请为“<”替换单词“extends”在代码中。
已解决:类“Item”不能包含“self.table_name”!