Skip to content

Commit

Permalink
Merge pull request #841 from owen2345/add-slug-to-search
Browse files Browse the repository at this point in the history
Ability to search for a post by it's slug
  • Loading branch information
owen2345 committed Sep 21, 2018
2 parents 8e43c40 + 7b531a9 commit 1c98b60
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/controllers/camaleon_cms/admin/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ def index

if params[:q].present?
params[:q] = (params[:q] || '').downcase
posts_all = posts_all.where("LOWER(#{CamaleonCms::Post.table_name}.title) LIKE ?", "%#{params[:q]}%")
posts_all = posts_all.where(
"LOWER(#{CamaleonCms::Post.table_name}.title) LIKE ? OR LOWER(#{CamaleonCms::Post.table_name}.slug LIKE ?)",
"%#{params[:q]}%",
"%#{params[:q]}%"
)
end

posts_all = posts_all.where(user_id: cama_current_user) if cannot?(:edit_other, @post_type) # filter only own contents

@posts = posts_all
Expand Down

0 comments on commit 1c98b60

Please sign in to comment.