Answer the question
In order to leave comments, you need to log in
Is it possible to make a certain kind of hyperlink in rails?
Good day!
ENV: Rails 5.1.4
There is a service (2-3 pages). All resources (pictures, fonts, etc.) are in assets.
you <%= image_tag "logo.png" %>
will give us
<img src="/assets/logo-b99dbe0ace3298702942689991a789129fcfb13538ad3216f6eee9c805c5a3af.png" alt="Logo">
начинались с точки
<img src="./assets/logo-b99dbe0ace3298702942689991a789129fcfb13538ad3216f6eee9c805c5a3af.png" alt="Logo">
были без первого /
<img src="assets/logo-b99dbe0ace3298702942689991a789129fcfb13538ad3216f6eee9c805c5a3af.png" alt="Logo">
location /fff/bbb/ccccc/ {
proxy_pass http://putin.ru;
}
Answer the question
In order to leave comments, you need to log in
I think the easiest option would be to use asset_path with interpolation:
<img src="<%= ".#{asset_path 'logo.png'}" %>" alt="Logo">
The URLs themselves are generated in RoR, and nginx only gives content, nothing more.
edgeguides.rubyonrails.org/asset_pipeline.html#cha...
The public path that Sprockets uses by default is/assets
.
This can be changed to something else:
You need to fix the config/environments/production.rb file
https://stackoverflow.com/a/37918186
Alternatively, you can generally store all the static on a separate CDN server:
DNS:
cloudfront (.mysite.com) CNAME --> mysite.cloudfront.com
I tried it, you won’t get links like ./assets/ through this
until you just made a monkeypatch for helpers, but this is a hard option too
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question