chris
chris

Reputation: 36937

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.

Upvotes: 10

Views: 6525

Answers (2)

honeydev
honeydev

Reputation: 1

For rails 6 may use javascript_pack_tag 'application', 'data-turbolinks-track': 'reload'

Upvotes: 0

rdvdijk
rdvdijk

Reputation: 4398

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.

Upvotes: 11

Related Questions