Last active
November 2, 2017 17:48
-
-
Save domagude/6b5dfe52962cb938caf02d529b8cc755 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
scope :by_category, -> (branch, category_name) do | |
joins(:category).where(categories: {name: category_name, branch: branch}) | |
end | |
scope :by_branch, -> (branch) do | |
joins(:category).where(categories: {branch: branch}) | |
end | |
scope :search, -> (search) do | |
where("title ILIKE lower(?) OR content ILIKE lower(?)", "%#{search}%", "%#{search}%") | |
end | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment