Skip to content
Snippets Groups Projects
Unverified Commit 97844f0e authored by Sébastien Gaya's avatar Sébastien Gaya Committed by GitHub
Browse files

Merge pull request #636 from noesya/fix/filter-categories

Fix filtre catégorie
parents cbd17b67 a2690272
No related branches found
No related tags found
No related merge requests found
......@@ -83,10 +83,7 @@ class Communication::Website::Post < ApplicationRecord
scope :ordered, -> { order(published_at: :desc, created_at: :desc) }
scope :recent, -> { order(published_at: :desc).limit(5) }
scope :for_author, -> (author_id) { where(author_id: author_id) }
scope :for_category, -> (category_id) {
descendant_ids = Communication::Website::Category.find_by(id: category_id)&.descendants&.map(&:id) || []
joins(:categories).where(communication_website_categories: { id: [category_id, descendant_ids].flatten }).distinct
}
scope :for_category, -> (category_id) { joins(:categories).where(communication_website_categories: { id: category_id }).distinct }
scope :for_pinned, -> (pinned) { where(pinned: pinned == 'true') }
scope :for_search_term, -> (term) {
where("
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment