Table of Content
Managing asset files
The entry point of the assets:
- The application.js
- The application.css
It is an entry point because in each file it includes the other files into the assets.
require name <-- means include that file.
require_tree . <-- means include all the files in the current directory.
There is a list of folders the asset pipeline will search.
/app/assets/
/lib/assets/
/vendor/assets/
Actually we can use the file others than the “application” name. Just clone the application.css
and .js into a new file and update the asset include name in the views/layout/application.html.erb
file.
Note: How about we want to include specific controller assets only?
- Remove the
require_tree .
in the application js and css file. - Use
<%= javascript_include_tag params[:controller] %>
when needed - or
<%= stylesheet_link_tag params[:controller] %>
when needed
What’s next? We’re going to take a look at “Creating gallery home page”.