Ruby on rails 作为带有中间表的列表
我试图使用act_as_list来订购一些项目,但是我对范围有问题,我希望范围是项目的组,但是我不知道如何做。这就是我现在拥有的:Ruby on rails 作为带有中间表的列表,ruby-on-rails,ruby-on-rails-4,Ruby On Rails,Ruby On Rails 4,我试图使用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 &
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
及
但是我在PG中遇到了一个错误,因为列组id不存在
有什么想法吗
has_one :group, through: :type
def group_id
type.group.id
end