Search code examples
ruby-on-railsasset-pipelinesprockets

why am i getting this routing error? ActionController::RoutingError (No route matches [GET] "/assets/toastr.js.map"):


I'm seeing this on localhost and prod:

ActionController::RoutingError (No route matches [GET] "/assets/toastr.js.map"):

I've tried including toastr.js.map in my manifest file: no luck. Also tried renaming the file to toastr.map.js - which immediately started throwing js errors in the console.

Is there a way to either automatically generate map files or ignore them?


Solution

  • I came across a similar problem recently. The way I solved it was by going inside the manifest file (e.g., public/assets/.sprockets-manifest-[md5hash].json, finding the logical names of the asset files and using those instead of the absolute paths.

    In my case, the fix was to remove the /assets/ prefix from the javascript_include_tag.

    In particular, in my html files I replaced this...

    = javascript_include_tag "/assets/admin/events/index.js"
    

    ...with this...

    = javascript_include_tag "admin/events/index.js"
    

    ...and recompiled assets. This seemed to do the trick for me.

    Here's a reference to the thread where I found this solution:
    Rails 5 + Heroku: Assets are not loaded in production, but works in localhost