Rails 7 ActionController::RoutingError stimulus controller with outdated digest - ruby-on-rails

Edit: A simpler example than my original question, my CSS is experiencing the same caching issue. Using the dartsass-rails gem, with the bin/rails dartsass:watch in development. Default configuration. Changes to my SASS files throw an error because Rails goes looking for an outdated digest.
ActionController::RoutingError (No route matches [GET] "/assets/application-01d05ee418a658bda88e5c4b0f5b5b1e7610df787a559e2151838d567ecfe62d.css"):
(Original post follows)
I have a stimulus controller app/javascript/editor/section.js. I am using a default Rails 7 configuration, using import maps along with Stimulus. I am running Puma locally in the development environment, with no changes to default configuration.
Whenever I make changes to my stimulus controller, the web server does not pick up the changes, and continues looking for the outdated controller digest, throwing 404 errors.
Javascript console errors like this:
GET http://localhost:3000/assets/editor/section-ca5da14b07bf02053399e5391d999b5870acc0d8783bb5d7844ce5a22f2278da.js
net::ERR_ABORTED 404 (Not Found)
Failed to register controller: editor (controllers/editor_controller) Error: 404 Not Found
http://localhost:3000/assets/editor/section-ca5da14b07bf02053399e5391d999b5870acc0d8783bb5d7844ce5a22f2278da.js
imported from http://localhost:3000/assets/controllers/editor_controller-0…31577c25719d88e9ca691b7736994a3335959f5513834f370414835d3.js
Puma console also complains:
ActionController::RoutingError (No route matches [GET] "/assets/editor/section-ca5da14b07bf02053399e5391d999b5870acc0d8783bb5d7844ce5a22f2278da.js"):
The reason for the error is known: the file has changed and been rebuilt, so the digest has changed. I just don't understand why the updated file isn't being picked up right away.
I have observed the behavior in Firefox and Chrome, with the Disable HTTP Cache (when toolbox is open) option enabled for both. Restarting the Puma web server will also correct the issue.

Related

rails ember-cli No route matches [GET] > "/javascripts/emberFrontend/vendor.js"

I am new to Ember and I'm trying to understand how the asset building works.
I have an existing Rails project that is in the middle of conversion to Ember, with ember-cli.
ember 1.13
ruby 2.1.6
rails 4.1.6
I keep getting these errors when trying to access ember pages, and I'm trying to isolate when, and what causes them:
Started GET "/javascripts/emberFrontend/vendor.js" for 127.0.0.1 at
2015-12-28 17:10:16 +0200
ActionController::RoutingError (No route matches [GET]
"/javascripts/emberFrontend/vendor.js"):
...
Started GET "/javascripts/emberFrontend/ember-frontend.js" for
127.0.0.1 at 2015-12-28 17:10:16 +0200
ActionController::RoutingError (No route matches [GET]
"/javascripts/emberFrontend/ember-frontend.js"):
for example, I take a page that is rendering fine and logs:
Started GET
"/assets/emberFrontend/vendor-b0892280be71c70102741f9d7feb0532.js" for
127.0.0.1 at 2015-12-28 17:53:15 +0200
Started GET
"/assets/emberFrontend/ember-frontend-affc24729a1c2e1a0a6a56334d2bb16a.js"
for 127.0.0.1 at 2015-12-28 17:53:15 +0200
And I make a change in the template code from:
<li class="reportsTab"><a href={{urls.reports}}>Reporting</a></li>
to:
<li>{{#link-to "merchant.reports"}}Reporting{{/link-to}}</li>
In order for one of the page tabs to direct to the ember code instead of the old one, similar to other changes made on that page. This change causes the errors above, and the browser page is blank.
What is puzzling me is that if I revert the change while the rails server is running, and then restart it - it doesn't stick, but if I stop the server, than make the change and rerun it, it does.
Clearly I am missing something in understanding how the ember server is building the assets, but I can't figure it out from any guides.
Also (and possbily related), my */emberFrontend/tmp directory doesn't clean.
Turned out my machine is to slow.
I changed the timeout in /config/initializers/ember.rb to 60
c.app :emberFrontend, path: Rails.root.join('emberFrontend').to_s, build_timeout: 60

mismatched file names causing routing errors in Rails 4 production assets:precompile

I am testing a Rails 4 app in production mode, on my development server. I use the command
'RAILS_ENV=production bundle exec rake assets:precompile', which completes with no errors reported.
I then run the WEBrick server with "RAILS_ENV=production rails server"
The app seems to run normally, but my log file shows the following fatal error
ActionController::RoutingError (No route matches [GET] "/assets/application-078fb9638cc0bc92bfa6c68332887622.js")
This must have something to do with the asset file signatures, but, how can I get rid of it?
It would appear that, by default, the property 'serve_static_assets' is not set in production.rb, which results in error messages in the server log. By setting the property to 'true', the precompilation produces the signature files referenced by the view code, eliminating the error message. This was observed using Rails 4.0.3

Why the stylesheet link path changed when I deploy the rails app to Heroku?

So in my localhost the stylesheet application.css is referenced as /assets/application.css and everything is fine, but when I deployed the app to Heroku, the css file is requested at the location /stylesheets/application.css. Is there something I didn't config right? I am just using stylesheet_link_tag "applicaiton" in my code.
Update, I actually got:
ActionController::RoutingError (No route matches [GET]
"/assets/application.css");
How does this happen, the file is right there.
I think you might not have the right stack on Heroku. You current stack doesn't support rails 3.1 and doesn't support Assets pipeline either.
To fix this you would need to switch to the Cedar stack: http://devcenter.heroku.com/articles/stack

rails 3.1 ActionController::RoutingError (No route matches [GET] "/assets/rails.png"):

Standard new rails app has issue showing the rails.png
ActionController::RoutingError (No route matches [GET] "/assets/rails.png"):
I have tried moving the .png file around to various places in assets and assets/images and also the older place 'public' or 'public/images' and changing the page but nothing has helped. Please answer if you have seen and resolved this. I have tried about 20 different combo's myself.
Version:
'rails', '3.1.0.rc4'
I just had a problem throwing a similar error. In my case I was starting the rails server in production mode in Mac OSX using the standard WEBrick. It threw this error because of the line:
config.serve_static_assets = false
in config/environments/production.rb.
That is set because on most production machines the web server itself will handle this.
It looks like you were having a different problem, but I'll post this here for others that run into this error.
It must have been an rc4 issue as the final release didn't have this issue.
11/27/11 - I now wonder if this was just due to the asset pipeline that was introduced in rails 3.1, requiring the rake assets:precompile command (compiles and copies images, css and js from app/assets to public/.
If anyone finds that to be the case, please add a comment!

How to set path to public in Rails 2.2.3 Application

I am trying to get a local instance up of an existing rails application. It is built on Rails 2.2.3. I keep getting errors that seem to me like I need to set the path to the public directory. When I run "scripts/server" and request pages, I get these errors:
ActionController::RoutingError (No route matches "/favicon.ico" with {:method=>:get}):
...
ActionController::RoutingError (No route matches "/stylesheets/cache/xxx.css" with {:method=>:get}):
ActionController::RoutingError (No route matches "/javascripts/cache/xxx.js" with {:method=>:get}):
How do I set the path to public? Could this have something to do with setting "RAILS_ROOT"?
Thanks
Check that in config/environments/{development,test,production}.rb, serve_static_assets is set to true. Otherwise, Rails will not serve the assets in /public.
Note that in production, you should likely have Apache or whatever web server you use serve those assets. Running it through Rails proper is an unnecessary slow down.

Resources