我找到了有关如何在Rails 6应用程序中添加jQuery
itself的在线资源,但是我很难找出如何要求rubygems.org gem]内部存在的jquery代码。 >。
我正在尝试从nested_form_fields gem中输入jQuery代码。
在Gemfile
中添加宝石:
gem 'nested_form_fields
运行bundle install
安装gem:
在app/assets/javascripts/application.js
中添加以下行,以要求来自第三方gem的jquery代码:
//= require nested_form_fields
就是这样。
将以下行添加到app/javascript/packs/application.js
中以加载到jquery中:
require("jquery")
在Gemfile
中添加宝石:
gem 'nested_form_fields'
运行bundle install
安装gem:
在app/javascript/packs/application.js
中添加以下行以引入nested_form_fields
gem中存在的javascript代码:
require("nested_form_fields")
[当我启动我的应用程序并查看Web检查器时,它显示以下内容:
中存在的javascript代码中要求。但无论如何,我还是尽力将其排除在外:错误:找不到模块'nested_form_fields'
我不希望它通过
yarn
起作用,因为nested_form_fields
不是纱线中的卷装。取而代之的是:我只是想在Ruby红宝石的inside
yarn add nested_form_fields ... => error An unexpected error occurred: "https://registry.yarnpkg.com/nested_form_fields: Not found".
我知道这将是我忘了做一些简单事情的事情之一,但是我已经从事了一段时间,另外一双眼睛也许能够迅速捕捉到它。
我找到了有关如何将jQuery本身添加到Rails 6应用程序的在线资源,但是我很难找到rubygems.org gem中存在的jquery代码的要求。我正在尝试...
Rails 6
的设计正在引导开发人员从asset pipeline
转向webpack
。看来,这意味着可能需要更新包含JavaScript的Rails中使用的宝石。