I’m encountering an issue with my Rails 7.2.1 app deployed on Render.com, where certain JavaScript controllers are not loading properly in production. The app uses importmap-rails to handle JavaScript dependencies. While the application runs fine in development on localhost:3000, I’m seeing multiple ActionController::RoutingError errors in production related to missing JavaScript controllers.
Error Details:
In my logs, I repeatedly get errors like the following:
E, [2024-10-09T18:58:47.913150 #122] ERROR – : [e054a74f-c079-4f4b-b7e1-9be6d8b19437]
Oct 9 08:58:47 PM[e054a74f-c079-4f4b-b7e1-9be6d8b19437] ActionController::RoutingError (No route matches [GET] “/assets/controllers/application”):
Oct 9 08:58:47 PM[e054a74f-c079-4f4b-b7e1-9be6d8b19437]
Oct 9 08:58:47 PMI, [2024-10-09T18:58:47.917968 #122] INFO – : [7163ac5d-3ab6-463e-ab02-10719eb2af7b] Started GET “/assets/controllers/map_controller” for 162.158.87.84 at 2024-10-09 18:58:47 +0000
Oct 9 08:58:47 PME, [2024-10-09T18:58:47.918486 #122] ERROR – : [7163ac5d-3ab6-463e-ab02-10719eb2af7b]
Oct 9 08:58:47 PM[7163ac5d-3ab6-463e-ab02-10719eb2af7b] ActionController::RoutingError (No route matches [GET] “/assets/controllers/map_controller”):
Oct 9 08:58:47 PM[7163ac5d-3ab6-463e-ab02-10719eb2af7b]
Oct 9 08:58:47 PMI, [2024-10-09T18:58:47.920656 #122] INFO – : [afb1a0b7-6c69-460a-857f-8ed5093eb65c] Started GET “/assets/controllers/navbar_controller” for 162.158.87.46 at 2024-10-09 18:58:47 +0000
Oct 9 08:58:47 PME, [2024-10-09T18:58:47.921539 #122] ERROR – : [afb1a0b7-6c69-460a-857f-8ed5093eb65c]
Oct 9 08:58:47 PM[afb1a0b7-6c69-460a-857f-8ed5093eb65c] ActionController::RoutingError (No route matches [GET] “/assets/controllers/navbar_controller”):
Oct 9 08:58:47 PM[afb1a0b7-6c69-460a-857f-8ed5093eb65c]
Oct 9 08:58:48 PMI, [2024-10-09T18:58:48.109947 #122] INFO – : [33daa566-21b7-490b-876c-685e37cfc94b] Started GET “/assets/google_maps_loader” for 162.158.86.249 at 2024-10-09 18:58:48 +0000
Oct 9 08:58:48 PME, [2024-10-09T18:58:48.110565 #122] ERROR – : [33daa566-21b7-490b-876c-685e37cfc94b]
Oct 9 08:58:48 PM[33daa566-21b7-490b-876c-685e37cfc94b] ActionController::RoutingError (No route matches [GET] “/assets/google_maps_loader”):
Oct 9 08:58:48 PM
Steps I’ve Taken:
Verified that importmap is correctly configured in config/importmap.rb, including the controllers:
pin_all_from “app/javascript/controllers”, under: “controllers”
Added the following to config/assets.rb:
Rails.application.config.assets.paths << Rails.root.join(‘app’, ‘javascript’)
Rails.application.config.assets.precompile += %w( controllers/*.js )
The bin/render-build.sh script includes the following to precompile assets:
bundle exec rails assets:precompile
Despite this, the errors persist in production.
Additional Info:
Locally, the importmap works as expected.
Environment:
Rails 7.2.1
Ruby 3.3.4
Request: Any insights into why these assets aren’t being found in production? Is there something wrong with my importmap setup, asset precompilation, or a different deployment configuration needed on Render?
Thanks in advance!