class ItemGroup < ActiveRecord::Base has_and_belongs_to_many :items, :join_table => 'item_item_groups' def all_items(offset, limit) self.items.where(on_display: true).order(:created_at).limit(limit).offset(offset).all end end