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

Fix agenda category children (#1663)

* fix agenda category children

* references
parent 7743e648
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,10 @@ class Communication::Website::Agenda::Category < ApplicationRecord
belongs_to :parent,
class_name: 'Communication::Website::Agenda::Category',
optional: true
has_many :children,
class_name: 'Communication::Website::Agenda::Category',
foreign_key: :parent_id,
dependent: :destroy
has_and_belongs_to_many :events,
class_name: 'Communication::Website::Agenda::Event',
join_table: :communication_website_agenda_events_categories,
......@@ -79,8 +83,9 @@ class Communication::Website::Agenda::Category < ApplicationRecord
end
def references
events +
website.menus
references = events + website.menus
references << parent if parent.present?
references
end
protected
......
......@@ -10,6 +10,7 @@ module Pathable
end
def update_children_paths
return unless respond_to?(:children)
children.each do |child|
child.update_column :path, child.generated_path
child.update_children_paths
......
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