Skip to content

Fix: Use Rails::Engine for Propshaft compatibility#72

Open
mickeytgl wants to merge 3 commits intomarcoroth:mainfrom
mickeytgl:main
Open

Fix: Use Rails::Engine for Propshaft compatibility#72
mickeytgl wants to merge 3 commits intomarcoroth:mainfrom
mickeytgl:main

Conversation

@mickeytgl
Copy link
Copy Markdown

@mickeytgl mickeytgl commented Jan 13, 2026

ReActionView's dev-tools assets were not found when using Propshaft because it used Sprockets-specific asset path registration.

Changed from Rails::Railtie to Rails::Engine, which automatically registers app/assets directories with both Sprockets and Propshaft.

I did notice the comment suggesting to put config.assets.precompile -= ReActionView::Railtie::PRECOMPILE_ASSETS in the initializer once I dug in and that works well, but I think it's still worth it since this would fix the root cause and it saves some time for people on propshaft from running into an error

Example

CleanShot 2026-01-13 at 13 34 56@2x

ReActionView's dev-tools assets were not found when using Propshaft
(Rails 8's default asset pipeline) because it used Sprockets-specific
asset path registration.

Changed from Rails::Railtie to Rails::Engine, which automatically
registers app/assets directories with both Sprockets and Propshaft.
@mickeytgl
Copy link
Copy Markdown
Author

@marcoroth No rush, but small bump

Comment on lines -5 to -11
# If you don't want to precompile ReActionView's assets (eg. because you're using propshaft),
# you can do this in an initializer:
#
# config.after_initialize do
# config.assets.precompile -= ReActionView::Railtie::PRECOMPILE_ASSETS
# end
#
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still want to keep this comment, no?

# config.assets.precompile -= ReActionView::Railtie::PRECOMPILE_ASSETS
# end
#
class Engine < Rails::Engine
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused why we need this 🤔

I have been using ReActionView in multiple apps with Propshaft and haven't come across this error. I wonder if it's something else that might be causing this issue. And coincidentally, changing to an Engine makes it go away too.

Co-authored-by: Chris Oliver <excid3@gmail.com>
@mickeytgl
Copy link
Copy Markdown
Author

mickeytgl commented Apr 1, 2026

Ok, I've dug deeper into this. It was kind of my fault by doing something weird, but this might still be relevant.

To reproduce:

  • RAILS_ENV=production bin/rails assets:precompile (don't ask, I had my reasons 😬 )
  • bin/dev
  • Go to any page

@marcoroth You might not run into this if you've never precompiled assets locally. Without a manifest, Propshaft falls back to its Dynamic resolver which checks the load path at runtime and finds the assets just fine.

But because ReActionView registers its assets as a Railtie instead of an Engine and Propshaft only auto-discovers assets from Engines, ReActionView's dev-tools JS files never make it into the precompiled manifest.

If that manifest is lying around in development (e.g. from a production precompile), Propshaft uses that and doesn't find the assets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants