class ApplicationController < ActionController::Base
  .
  .
  .
  # Paginuj list, jeli jest dostpna, w przeciwnym przypadku wywoaj domyln metod paginate
  def paginate(arg, options = {})
    if arg.instance_of?(Symbol) or arg.instance_of?(String)
      # Uyj domylnej funckji paginate
      collection_id = arg # arg to na przykad :specs lub "specs"
      super(collection_id, options)
    else  
      # Paginacja rczna
      items = arg # arg jest list elementw, e.g., users
      items_per_page = options[:per_page] || 10
      page = (params[:page] || 1).to_i
      result_pages = Paginator.new(self, items.length, items_per_page, page)
      offset = (page - 1) * items_per_page
      [result_pages, items[offset..(offset + items_per_page - 1)]]
    end
  end
end

