Skip to content

Instantly share code, notes, and snippets.

@alexvbush
Created July 14, 2014 01:22
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 alexvbush/4301344b1a94e0d7ab05 to your computer and use it in GitHub Desktop.
Save alexvbush/4301344b1a94e0d7ab05 to your computer and use it in GitHub Desktop.
Articles Search mixin.
module ArticlesSearch
def articles_search(search_criteria, state = nil)
@articles = Article.includes(:categories).where('title LIKE ? OR categories.name LIKE ?', "%#{search_criteria}%", "%#{search_criteria}%")
if state
@articles = @articles.where(state: state)
end
@articles
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment