Florian Osterhus

Joined

870 Experience
8 Lessons Completed
0 Questions Solved

Activity

closed

missed gem "sprockets-rails", "~> 3.4" -.-'

Thank you for your answer. I have included it as described above.

In app/assets/config/manifest.js, I ensured the builds folder is linked:

//= link_tree ../images
//= link_tree ../builds

Recently, I ran into an issue while setting up esbuild and Tailwind CSS in my Rails 7 app. Despite following all the recommended steps, my stylesheets and JavaScript files simply wouldn't load in the browser. The Rails logs repeatedly showed:

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

What I Tried

  1. Correct Asset Tags in application.html.erb
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
  1. Build Scripts in package.json
"scripts": {
  "build": "esbuild app/javascript/*.* --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets",
  "build:css": "tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --minify"
}
  1. Assets Folder Configuration

I verified that the compiled files are being created correctly in app/assets/builds:

ls -l app/assets/builds
# Output:
# -rw-r--r--  application.css
# -rw-r--r--  application.js
# -rw-r--r--  application.js.map
  1. Updated the Manifest

In app/assets/config/manifest.js, I ensured the builds folder is linked:

//= link_tree ../images
//= link_tree ../builds
  1. Added Asset Path to config/application.rb
config.assets.paths << Rails.root.join("app/assets/builds")
  1. Ensured Public File Server Is Enabled

In config/environments/development.rb:

config.public_file_server.enabled = true

The Outcome

Even with all these changes, the browser still throws the same error:

No route matches [GET] "/assets/application.css"
No route matches [GET] "/assets/application.js"

I’ve verified the files are being built correctly, so the issue seems to lie in how Rails serves or routes these files. Restarting the server (bin/dev) and clearing the cache made no difference.


Conclusion

Everything is set up as it should be, yet the assets refuse to load. I know the files are being generated in app/assets/builds, but Rails still cannot find them. If anyone has run into this issue and found a solution, I’d love to hear from you!