Created
November 2, 2017 17:43
-
-
Save domagude/792df7c0595d0dc74547355a8e9c556b 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
def get_posts | |
branch = params[:action] | |
search = params[:search] | |
category = params[:category] | |
if category.blank? && search.blank? | |
posts = Post.by_branch(branch).all | |
elsif category.blank? && search.present? | |
posts = Post.by_branch(branch).search(search) | |
elsif category.present? && search.blank? | |
posts = Post.by_category(branch, category) | |
elsif category.present? && search.present? | |
posts = Post.by_category(branch, category).search(search) | |
else | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment