inertiajs / inertia-rails

The Rails adapter for Inertia.js.
https://inertia-rails.dev/
MIT License
574 stars 45 forks source link

Issue using eager_load in external gem #78

Closed aviemet closed 2 years ago

aviemet commented 2 years ago

After upgrading to 1.12.1, a gem I wrote is now throwing an error when it runs. I'm not sure if this is something which might effect others, or if it's a sub-optimal implementation on my part.

In my gem, I use Rails.application.eager_load! so that I can load all ActiveRecord models and do some inspection. With the latest version, that throws the following error:

undefined method 'helper' for ActionController::API:Class

Which traces back to this line on the Controller module in InertiaRails.

I've been searching for a better way to eager load models, but I can't seem to find one. Would appreciate some guidance.

0xDing commented 2 years ago

ref https://github.com/inertiajs/inertia-rails/pull/77

BrandonShar commented 2 years ago

Thanks for the report @aviemet and the fix @0xDing ! This change is going to require us to drop support for an older version of Rails so I think it seems appropriate to do a major version bump. I'll get that done this weekend!

BrandonShar commented 2 years ago

Just tagged Inertia v2.0. Please take a look and see if this resolves your issues!

Feel free to re-open if it does not.