Rails: Include External JavaScript

前端 未结 3 925
一生所求
一生所求 2021-02-01 08:42

I want to use a JavaScript library such as a jQuery plugin. Do I use the Rails asset pipeline? Or should I include it with a javascript_include_tag? What are my options and what

3条回答
  •  孤城傲影
    2021-02-01 09:21

    To access Javascript on a single file, javascript_include_tag is the best option.

    With that what you can do is too add 'Rails.application.config.assets.precompile += %w( yourfilename.js )' to your 'config/initializers/assets.rb' file.

提交回复
热议问题