Spina v2.11 `Spina::MenuPresenter.to_html` results in `NoMethodError` when calling `.homepage?`
kfrz opened this issue · 0 comments
When attempting to render a navigation with a given Spina::MenuPresenter
, ruby/3.1.3/lib/ruby/gems/3.1.0/gems/activemodel-7.0.3.1/lib/active_model/attribute_methods.rb:458
is called. This results in a NoMethodError
when following the recommended navigation guide.
.../attribute_methods.rb:458:in `method_missing': undefined method `homepage?' for
#<Spina::NavigationItem id: 36, page_id: 3, navigation_id: 3, position: 0, ancestry: nil, created_at: "2022-12-17 13:11:20.015606000 +0000", updated_at: "2022-12-17 13:11:20.015606000 +0000"> (NoMethodError)
Looks like the homepage?
method is defined on the ::Page
object class. Each Navigation
has_many Pages
:through NavigationItems
.
Mapping with Navigation#pages.map(&:homepage?)
works - so it seems NavigationItem#homepage?
is the culprit. Somewhere along the way NavigationItems
has changed, but it's my first foray into this project's source and I would defer to more familiar devs on the potential path forward. My suggestion would be to delegate this homepage?
method or wire up the NavigationItems
class in such a way that it gracefully handles this error.
https://github.com/SpinaCMS/Spina/blob/main/app/presenters/spina/menu_presenter.rb#L93