Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby on rails javascript_include_tag :defaults

What the how the, where the..

<%= javascript_include_tag :defaults %>

this little evil line is pulling in 3 additional JavaScript that I could essentially give less then a damn about. In fact I would like to use that to redefine some defaults on a per page basis. However I can't seem to figure out where those defaults are defined.

Ive been on google and bing looking for answers but I yield none. I keep coming up with a document or 3 that explain using it, but not how I can use it.

like image 676
chris Avatar asked Oct 01 '11 07:10

chris


1 Answers

Use the Rails API documentation for this.

If the application is not using the asset pipeline, to include the default JavaScript expansion pass :defaults as source. By default, :defaults loads jQuery, and that can be overridden in config/application.rb:

config.action_view.javascript_expansions[:defaults] = %w(foo.js bar.js)

When using :defaults, if an application.js file exists in public/javascripts it will be included as well at the end.

like image 163
rdvdijk Avatar answered Nov 14 '22 15:11

rdvdijk