Installed Rails 6.0.3. Ran rails new [app], started the server, loaded the homepage and the server logs are showing this routing error. Any ideas? Here's my routes file which I haven't touched.
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
Going into Chrome's Dev Tools > Application > Clear Storage fixed my issue.
If you want to use the service-worker in the rails, please refer to as follows
https://github.com/rossta/serviceworker-rails
Related
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.
Getting error while creating webservices on Ruby on Rails.
I have followed what ever the steps mentioned in this.
After starting the Server with rails server command, when I am hitting http://localhost:3000/hello_message/wsdl, it's giving me the error:
ActionController::RoutingError (No route matches [GET] /hello
message/wsdl)
routes.rb:
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
That tutorial is from 2008, I'm not quite sure but maybe this could help you to fix it
Add resources :hello_messages
or
get '/hello_messages/wsdl' => 'hello_messages#hello_messages'
This should be inside of Rails.application.routes.draw do
But I'll recommend you to look for more recent tutorials
I am following the online version of Rails Tutorial. The Sample_app in chapter 3 works fine locally, but when pushed to Heroku, the home page is found but not the other pages. Running heroku logs after trying to see the About page gives me (along with much else) the error above:
2015-08-09T02:56:43.916991+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/about"):
My routes.rb file is
Rails.application.routes.draw do
root 'static_pages#home'
get 'static_pages/help'
get 'static_pages/about'
end
I have followed the directions carefully. I tried deleting and recreating the Heroku file. I did web searches and tried some things to no avail. My gemfile is straight from the online version of the book, which is using current versions.
Solved: #thedanotto had me run heroku run rake routes which showed that the help and about pages were directed to {root}/static_pages/about rather than {root}/about. I am still puzzled why the tutorial gives the about routes, which appear not to work as expected, and welcome any further comment, but I am marking this as solved.
Whenever I can't find a route, I run the terminal command
rake routes
Since you're on heroku you'll want to run
heroku run rake routes
Which will return something similar to the following.
Prefix Verb URI Pattern Controller#Action
static_pages_about GET /static_pages/about(.:format) static_pages#about
So that shows that you can go to www.[heroku_app_name].herokuapp.com/static_pages/about And it will bring you to the page you want. You can also add a link to the page in a view by putting the following line of code within a view.
<%= link_to("About", static_pages_about_path) %>
That's all good stuff to know. But let's talk about using the controller action: static_pages#about with the path /about
Switch the following in routes.rb from
get 'static_pages/about'
to
get "static_pages/about", path:"/about"
or alternatively
get "/about", to: "rabbits#about"
You can read more about Routes here
If it works fine locally, I assume you've set up the controllers, views etc properly.
Have you made sure to commit all those necessary changes then push?
e.g.
git add .
git commit -am "Added route"
git push heroku master
Are you accessing the about page using the following URL ?
http://YourHerokuAppName.herokuapp.com/static_pages/about
[ Replace "YourHerokuAppName" with your Heroku App Name]
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!
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.