i just started my first ruby app.
I copy the css and js files needed for my application to the assets folder and when i run the app all the css and js loaded to the page and i dont want that
My view is simply
hello
my application.css is only comments
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
Why all assets are loaded? Can i "disable" this?
All i want is to define the files (css,js) needed in the view file with specific order and load js only needed for the specifif page
There are special comments. Rails's preprocessor interprets it and inserts your files.
*= require_self
*= require_tree .
Read The Asset Pipeline . 2.4 Manifest Files and Directives.
if you write *=require tree that means all the js on the javascript folder will be added, and same for the css. so remove those lines. And at the same time you can use the assets manager to your application to manage your assets(make it page specific) to under stand assets management i will recommend you to check http://railscasts.com/episodes/279-understanding-the-asset-pipeline?view=asciicast and https://rails-assets.org/
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.