> On Jul 10, 2016, at 8:43 AM, 'krfg' via Ruby on Rails: Talk 
> <[email protected]> wrote:
> 
> The default setting in my application.html.erb is:
> 
> <%= stylesheet_link_tag     'application', media: 'all', 
> 'data-turbolinks-track': 'true' %>
> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'true' %>
> 
> I have a cusom.css.scss file in app/assets/stylesheets which is included as 
> part of the application.css file included in the site layout, supposedly 
> because of the 
> stylesheet_link_tag 'application' line of code.
> I therefore planned to put all the javascript (jQuery and bootstrap) for my 
> application in custom.js inside app/assets/javascript.
> Would rails automatically load this file or am I expected to explicitly tell 
> rails to load it?
> 
> What confuses me is that in the Ruby on Rails tutorial, when jQuery is used, 
> it is put inside the html.erb document, like in Chapter 13, so that on the 
> one hand it is used a custom.css.scss file as stylesheet, on the other hand, 
> when javascript is required, it is inserted inside the html.erb document.

If you use jQuery, you have to guarantee that it loads before you rely on it. 
Load tree (the directive in the last line of application.js) loads the 
app/assets/javascripts folder, as well as the vendor/assets/javascripts folder, 
and any scripts declared by Gems, in filesystem order. I don't know the order 
of operations here off the top of my head, but it seems likely that you would 
have a hard time guaranteeing that jQuery was loaded before your script tried 
to use it, particularly if your script name started with an i or lower letter.

Walter

> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/18b8f034-eff8-498e-9e60-a3880094bf9c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/5D58BB10-8D4F-42BB-9A88-367769244124%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to