Getting the following error:
ActionController::RoutingError (No route matches "/public/images/download.png" with {:method=>:get}):
This error means that a request is being made for the following URL:
http://YOURSERVER/public/images/download.png
Typically, this correlates to file in your application's home directory of:
public/public/images/download.png
Note the "public" dir nested within the "public" dir
Related
ActionController::RoutingError (No route matches [GET] "/assets/application.js-1246371c75312771378dc97fa604ef404c73f9b477b5eb8f4c6ebb2fd2e1e323.map"):
My build script in package.json is:
"build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds",
So I see under assets, under builds, my application.js, and my application.js.map
But developer console shows 404 on the source map, and the server logs show that resource as an error. What am I doing wrong?
Corresponding to this thread
Setting config.assets.debug = false will solve that error
The config.assets.debug = false workaround has undesirable side effects. Missing debug log messages etc.
A cleaner solution is to add the following route definition to config/routes.rb:
if Rails.env.development?
redirector = ->(params, _) { ApplicationController.helpers.asset_path("#{params[:name].split('-').first}.map") }
constraint = ->(request) { request.path.ends_with?(".map") }
get "assets/*name", to: redirect(redirector), constraints: constraint
end
This resolves the sourcemaps for JS and CSS files and keeps asset debugging intact.
In Grails 3.3.0, I'm having an issue with getting it to use the UrlMappings that I've defined. For instance, I'm trying to have "/" map to the default controller/action.
This works locally (I've turned on logging for 'org.grails.plugins.web.mapping').
I see this in log:
2017-09-01 18:08:05,254 [http-nio-8080-exec-2] DEBUG org.grails.web.mapping.DefaultUrlMappingsHolder - Attempting to match URI [/] with pattern [500]
2017-09-01 18:08:05,254 [http-nio-8080-exec-2] DEBUG org.grails.web.mapping.DefaultUrlMappingsHolder - Attempting to match URI [/] with pattern [/]
2017-09-01 18:08:05,302 [http-nio-8080-exec-2] DEBUG org.grails.web.mapping.DefaultUrlMappingsHolder - Matched URI [/] with pattern [/], adding to posibilities
...and the default controller/action is what I see.
In the Tomcat container, I see this:
09-01 17:44:35,968 [ajp-bio-8009-exec-1] DEBUG org.grails.webflow.mvc.servlet.GrailsFlowHandlerMapping - Looking up Grails controller for URI [/]
2017-09-01 17:44:36,019 [ajp-bio-8009-exec-1] TRACE org.grails.web.servlet.mvc.GrailsDispatcherServlet - Testing handler map [org.grails.web.mapping.mvc.UrlMappingsHandlerMapping#17ef7838] in DispatcherServlet with name 'grailsDispatcherServlet'
but I don't see it attempt to match against "/". Or the 500, for that matter. Any ideas on what else to look for to troubleshoot this?
I have a stylesheet I want to use in my HTML emails at the path:
app/vendor/assets/stylesheets/inspinia/email_templates/email-styles.css
I am using the Premailer-Rails gem for my email styling.
In my mailer.html.erb layout, I have the following:
<%= stylesheet_link_tag "inspinia/email_templates/email-styles.css", media: 'all' %>
However, in my logs on Heroku, I get the following message:
app[web.1]: [923202d9-b3f1-4b9a-9f42-7b70dcc01d92] Started GET "/stylesheets/inspinia/email_templates/email-styles.css" for 54.167.56.21 at 2016-12-23 23:25:08 +0000
app[web.1]: [923202d9-b3f1-4b9a-9f42-7b70dcc01d92]
2016-12-23T23:25:08.286725+00:00 app[web.1]: [923202d9-b3f1-4b9a-9f42-7b70dcc01d92] ActionController::RoutingError (No route matches [GET] "/stylesheets/inspinia/email_templates/email-styles.css"):
So how do I figure out/specify the correct path for this stylesheet in production?
try move email-styles.css to /public/assets/ folder, or add it to the assets pipeline.
Premailer-rails wiki:
File System: If there's a file inside public/ with the same path as in the URL, it is read from disk. E.g. if the URL is http://cdn.example.com/assets/email.css the contents of the file located at public/assets/email.css gets returned if it exists.
Asset Pipeline: If Rails is available and the asset pipeline is enabled, the file is retrieved through the asset pipeline. E.g. if the URL is http://cdn.example.com/assets/email-fingerprint123.css, the file email.css is requested from the asset pipeline. That is, the fingerprint and the prefix (in this case assets is the prefix) are stripped before requesting it from the asset pipeline.
Add the following into config/initializers/assets.rb:
Rails.application.config.assets.precompile << 'email-styles.css'
Rails.application.config.assets.paths << Rails.root.join('app/vendor/assets/stylesheets/inspinia/email_templates')
Then use <%= stylesheet_link_tag 'email-styles.css', media: 'all' %> in the template.
I deployed rails application in cPanel and run rails project but always server return to me this error:
No route matches "/index.html.var" with {:method=>:get}
http://railsbama.tk/
Notice: this project is hello world and has one controller('home') and one action 'index' only return 'hello world'.
Try setting your root path to the controller and action: root to: 'home#index'
I moved image to assets/images path from public/images
I have image:
<%= image_tag("login_logo.png", :id => "login_logo") %>
I moved it from public folder to assets and changed path.
It is visible and working ok, but I get error in my console:
Started GET "/assets/logo_PG.png" for 127.0.0.1 at 2012-10-10 23:42:53 +0300
Served asset /logo_PG.png - 304 Not Modified (0ms)
ActionController::RoutingError (No route matches [GET] "/images/login_logo.png")
How can I solve this ?
Everything in subdirectories of assets (regardless whether it is an image, JS, etc.) is by default available under /assets/name.extension. So just make sure you refer to the image with the path /assets/login_logo.png, or use the asset_path helper:
<%= asset_path('login_logo.png') %>