I have a rails app in which I have added a new asset. I have added a new folder named information
, in the assets folder, in which there is a PDF called xyz.pdf
.
The problem is that I am trying to make a link to that PDF, however the application throws up an error: No route matches [GET] "/assets/information/xyz.pdf"
I have added the new asset in the config/application.rb
file :
config.assets.paths << "#{Rails.root}/app/assets/information"
This is the link I am using :
<%= link_to "Information Pack", "assets/information/xyz.pdf", :class => "links" %>
When using the asset pipeline, you should refer to any asset in the application with:
<%= link_to "Information Pack", asset_path("information/xyz.pdf"), :class => "links" %>
or
<%= link_to "Information Pack", asset_path("xyz.pdf"), :class => "links" %>
This would generate a different path depending the running environment and the asset version number.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With