Asset Pipeline Reserves 3

I'm just looking for a little clarity for a better understanding of the Rails pipeline. I put my stylesheets and javascripts in applications / assets / javascripts and app / assets / stylesheets. Now I'm trying to get these views for rendering on my page, but so far nothing is visible. I wanted to see if anyone could confirm if the following looks right.

In my layouts / application I have

<%= stylesheet_link_tag "fullcalendar" %> <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "jquery.js" %> <%= javascript_include_tag "jquery.rest.js" %> <%= javascript_include_tag "rails.js" %> <%= javascript_include_tag "application.js" %> <!-- these are needed for the calendar. --> <%= javascript_include_tag "jquery-ui-1.8.11.custom.min.js" %> <%= javascript_include_tag "fullcalendar.js" %> <%= javascript_include_tag "calendar.js" %> 

And my index.html.erb looks like

 <html> <head> <link href="/stylesheets/fullcalendar.css" media="screen" rel="stylesheet" type="text/css" /> <script type='text/javascript' src='/javascripts/jquery.js'></script> <script type='text/javascript' src='/javascripts/fullcalendar.js'></script> <script type='text/javascript' src='/javascripts/calendar.js'></script> <script type='text/javascript' src='/javascripts/jquery-ui-1.8.9.custom.min.js'></script> <script type='text/javascript' src='/javascripts/jquery.rest.js'></script> 

I missed something or just became a real novice (any constructive criticism is welcome)

+4
source share
2 answers

in your layouts / application you just need to:

 <%= javascript_include_tag "application" %> <%= stylesheet_link_tag "application", media: "all" %> 

and in app / assets / stylesheets / application.css you just need to:

  *=require_self *=require_tree . 

and in app / assets / javascripts / application.js

 //= require jquery //= require jquery_ujs //= require_tree . 

And there you need to include all the files

You will have problems with production, if you include js files, to avoid this, you should add such files, ex: "fullcalendar.js" to config / production.rb, config. assets.precompile + =% W (fullcalendar.js) and then run rake asset: precompile

+4
source

You can see a brief overview in the Ryan Bates Video: # 279 Understanding the Asset Pipeline Project . For more information, go to RailsGuide: Asset Pipeline .

Both helped me a lot.

+1
source

Source: https://habr.com/ru/post/1401792/


All Articles