How to set path to public in Rails 2.2.3 Application - ruby-on-rails

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.

Related

Rails 7 ActionController::RoutingError stimulus controller with outdated digest

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.

ActionController::RoutingError (No route matches [GET] "/serviceworker.js"):

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

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

Rails Routes issue on heroku

My app working fine on localhost but when I push app on heroku, its show error on heroku. Heroku log below
ActionController::RoutingError (No route matches [POST] "/forgot_password"):
and below is rake routes result
My app working fine on localhost but when I push app on heroku, its show error on heroku log below
ActionController::RoutingError (No route matches [POST] "/forgot_password"):
Your routes suggest the path as "/api/v1/forgot_password". And you are getting the path error as "/forgot_password".
Check the form where you are routing to this path.
I think you forgot add routes.rb file with your commit. you need to push that file on heroku

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!

Resources