-
-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Attempting to upgrade the view_component gem and running into an issue.
Bridgetown] Exception raised: NoMethodError
[Bridgetown] undefined method `resource' for #<IconComponent:0x00000001113f4398 #... >>>
[Bridgetown] 1: /Users/drbragg/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bridgetown-view-component-2.0.0/lib/bridgetown-view-component/bridgetown/view_component_helpers.rb:54:in `method_missing'
[Bridgetown] 2: /Users/drbragg/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bridgetown-routes-1.3.4/lib/bridgetown-routes/view_helpers.rb:19:in `roda_app'
[Bridgetown] 3: /Users/drbragg/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bridgetown-routes-1.3.4/lib/bridgetown-routes/view_helpers.rb:23:in `request'
[Bridgetown] 4: /Users/drbragg/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bridgetown-view-component-2.0.0/lib/bridgetown-view-component/bridgetown/view_component_helpers.rb:52:in `method_missing'
[Bridgetown] 5: /Users/drbragg/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/view_component-3.12.1/lib/view_component/base.rb:321:in `maybe_escape_html'
[Bridgetown] 6: /Users/drbragg/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/view_component-3.12.1/lib/view_component/base.rb:336:in `safe_render_template_for'
[Bridgetown] 7: /Users/drbragg/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/view_component-3.12.1/lib/view_component/base.rb:109:in `render_in'
[Bridgetown] 8: /Users/drbragg/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bridgetown-core-1.3.4/lib/bridgetown-core/ruby_template_view.rb:35:in `render'
...
Doing a bit of digging I found a change in VC 3.9 that might(?) be a source of the problem: ViewComponent/view_component#1950 specifically the changes to lib/view_component/base.rb:310.
It looks like when request is called it's calling the request method in bridgetown-routes/lib/bridgetown-routes/view_helpers.rb:22 which looks at view.resource&.roda_app. In my case the "view" in question appears to be the component instance.
If I add
def resource
nil
endto the BaseComponent everything boots and renders as normal. Not 100% sure if this is the correct work around it just works for me.
Versions
bridgetown: 1.3.4
bridgetown-view-component: 2.0
view_component: >= 3.9.0
config/initializers.rb
Bridgetown.configure do |config|
init :"bridgetown-view-component" do
ViewComponent::Base.config.view_component_path = "src/_components"
end
init :ssr
init :"bridgetown-routes"
endLet me know if there's any other information I can provide that might be helpful.