ViewComponent / view_component

A framework for building reusable, testable & encapsulated view components in Ruby on Rails.
https://viewcomponent.org
MIT License
3.33k stars 440 forks source link

Coexistence issues with `active_scaffold` gem #2032

Open juankiz opened 6 months ago

juankiz commented 6 months ago

My best guess is that something similar to either this issue or this issue that is clashing with this file on active_scaffold but since I'm using rails 7.0 I cant use the render_component method.
I would stick to just add the render_component method back directly on my application code, but since it'll be removed in the future, I'm not sure what's the best way to move forward with this.

Steps to reproduce

On a working Rails + ViewComponent app, add the active_scaffold gem. You can view a minimal example on this repo

Expected behavior

Actual behavior

An exception is thown:

'#<HelloWorldComponent:0x00000001209635e0 @_routes=nil>' is not an ActiveModel-compatible object. It must implement :to_partial_path.

Backtrace:

actionview (7.0.8.3) lib/action_view/renderer/abstract_renderer.rb:82:in `partial_path'
actionview (7.0.8.3) lib/action_view/renderer/object_renderer.rb:20:in `render_object_derive_partial'
actionview (7.0.8.3) lib/action_view/renderer/renderer.rb:94:in `render_partial_to_object'
actionview (7.0.8.3) lib/action_view/renderer/renderer.rb:53:in `render_partial'
active_scaffold (3.7.4) lib/active_scaffold/extensions/action_view_rendering.rb:200:in `render'
active_scaffold (3.7.4) lib/active_scaffold/extensions/action_view_rendering.rb:69:in `render'
app/views/home/index.html.erb:1

System configuration

Rails version: 7.0.8.3

Ruby version: 3.3.1

Gem version: 3.12.1

reeganviljoen commented 6 months ago

@juankiz thank you for the report

I don't know exactly what may have caused this and how to fix it, but if I have some time to investigate this I will let you know what I find

Also @joelhawksley @camertron what do you think

joelhawksley commented 6 months ago

@juankiz I'd love for us to find a way for ViewComponent to not conflict with active_scaffold. Might you be up for writing a PR with a failing test and see if you can come up with a fix?

planetmcd commented 3 months ago

Hey @joelhawksley, long time no see. I hope all is well.

I just stumbled upon this bug too. I'm looking to dump ActiveScaffold, so will just do that before I introduce ViewComponents. Just chiming in as a second example.

joelhawksley commented 2 months ago

Oh hey @planetmcd! I still say not in my parish because of you 😂

Thanks for the corroborating report ❤

planetmcd commented 2 months ago

Love that. Thanks for spearheading this library!