我试图使用act_as_list来订购一些商品,但是我的范围有问题,我希望范围是商品的组,但我不知道怎么做。这就是我现在所拥有的:
class Group < ActiveRecord::Base
has_many :types
has_many :items, through: :types
end
class Type < ActiveRecord::Base
belongs_to :group
has_many :items
end
class Item < ActiveRecord::Base
belongs_to :type
acts_as_list scope: ?
end
我尝试了范围:[type :: group]但它没有用,我试过:
has_one :group, through: :type
和
def group_id
type.group.id
end
但后来我的PG出错,因为列group_id不存在......
有什么想法吗?