3 class HasManyThroughList < BaseList
4 attr :list, :list_name, :list_manifest,
5 :belongs_to, :has_many, :has_one
14 @list_list_conf = @manifest.list(@item_name).lists[list_name] || {}
15 @association_name = @list_list_conf['association_name']
16 @has_many_conf = @manifest.model(@item_name).associations['has_many'] || {}
17 @association_conf = @has_many_conf[@association_name] || {}
18 @association_through_model_name = @association_conf['through']
19 @association_through_model = @association_through_model_name.classify.constantize
20 @association_model_name = @association_conf['model']
21 @association_model = @association_model_name.classify.constantize
22 @foreign_key = @association_conf['foreign_key']
23 if @association_model.content?
24 @owner_model = @association_model.owner_model
25 @owner_table_name = @owner_model.table_name if @owner_model
30 w = @association_model.list_where
31 w += ' and ' unless w.blank?
32 [w + @association_through_model.table_name + '.' + @foreign_key + ' = ?', root_item.id]
36 {@association_through_model.table_name => {@item_name => {}}}
40 @association_model.where(self.where(root_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size)
43 def paginate root_item
44 Kaminari.paginate_array(Array.new(@association_model.where(self.where(root_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size)
47 def self.add_action item_name, action_name, list_name, list_conf