简体   繁体   中英

Rails app not loading stylesheet or js file

In my content/themes/default/views/layouts/default.html.erb file I have these set:

<%= stylesheet_link_tag 'default' %>
<%= javascript_include_tag 'default' %>

those files are in content/themes/default/assets/stylesheets and javascripts respectively. Yet in my browser my site throws a 404 on both /stylesheets/default.css and /javascripts/default.js

From the docs https://apidock.com/rails/ActionView/Helpers/AssetTagHelper/javascript_include_tag

Sources may be paths to JavaScript files. Relative paths are assumed to be relative to assets/javascripts, full paths are assumed to be relative to the document root. Relative paths are idiomatic, use absolute paths only when needed.

So as far as I understand from the docs, if you want to include the asset in that manner you sould put in asstes/javascripts. Another option is including it using it's full path as docs suggest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM