Skip to content

Instantly share code, notes, and snippets.

@samnang
Created October 17, 2013 17:27
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 samnang/7028901 to your computer and use it in GitHub Desktop.
Save samnang/7028901 to your computer and use it in GitHub Desktop.
def fetch_cases
cases = (admin? || csm?) ? Case : current_user.cases
cases = cases.order("#{sort_column} #{sort_direction}")
cases = cases.recent.pending_first.includes(:entries, :case_type, :user, :client)
cases = cases.page(page).per(per_page)
if search_term.present?
cases = cases.search_for(search_term)
end
cases
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment