Skip to content

Instantly share code, notes, and snippets.

@nglx
Created July 25, 2013 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nglx/6078432 to your computer and use it in GitHub Desktop.
Save nglx/6078432 to your computer and use it in GitHub Desktop.
module Scope
def self.included(base)
base.has_scope :with_name_like
base.has_scope :with_title_like
end
end
class PostsController < ApplicationController
include Scope
def index
search_params = params[:post_search] || {}
@posts = apply_scopes(Post, search_params)
end
end
class PostProcessor
include HasScope
include Scope
def process(scope_hash)
posts = apply_scopes(Post.all, scope_hash)
# ....
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment