Open
Description
Hi,
I have page model with tree structure. I also have scope based on status:
class Page < ApplicationRecord
has_closure_tree
STATUSES = %w[draft published].freeze
enum status: STATUSES
scope :published, -> { where(status: :published) }
end
I need to create navigation menu which will display only published pages. How can I do this?
If I'm trying to use:
Page.published.hash_tree
I'm getting error:
NoMethodError: undefined method `[]=' for nil:NilClass
... and I understand why (after scope it's not a tree structure any more). Is there any way to achieve that?
Thanks!