Module: Findit

Defined in:
lib/findit/cache.rb,
lib/findit.rb,
lib/findit/single.rb,
lib/findit/version.rb,
lib/findit/collections.rb,
lib/findit/will_paginate.rb

Overview

Example usage:

#/app/finders/posts_finders.rb
class PostFinder
  include Findit::Collections

  cache_key do
    [@user.id, @query]
  end

  def initialize(user, options = {})
    @user = user
    @query = options[:query]
  end

  private

  def find
    scope = scope.where(user_id: @user.id)
    scope = scope.where('description like :query', query: @query) if @query.present?
    scope
  end
end

#/app/controllers/posts_controller.rb
class PostsController < ApplicationController
  def index
    @posts = PostFinder.new(user: current_user)
  end
end

#/app/views/posts/index.html.erb
<% cache(@posts, tags: @posts.cache_tags, expires_in: @posts.expires_in) do %>
  <%= render 'post' colection: @posts, as: :post%>

Defined Under Namespace

Modules: Cache, Collections, Single, WillPaginate

Constant Summary collapse

VERSION =
"1.4.1".freeze