Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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