0

我正在使用 Rails 4.2.3。如何在我的应用程序的一个页面上仅包含特定的 Jquery 库 (jquery-cookie)?我的 Gemfile 中有这颗宝石

gem 'jquery-cookie-rails'

在我的“app/views/user_objects/index.html.erb”页面上,我尝试在顶部添加这个

<%= javascript_include_tag 'jquery.cookie' %>

但它会导致错误“Sprockets::Rails::Helper::AssetNotPrecompiled in UserObjects#index”。

4

1 回答 1

2

利用,

<%= javascript_include_tag 'js.cookie' %>

因为 jquery.cookie 被 js.cookie 取代了。

如果这不起作用,请使用 js.cookie gem,

https://github.com/freego/js_cookie_rails

gem 'js_cookie_rails'

<%= javascript_include_tag 'js.cookie' %>
于 2016-03-01T16:11:41.700 回答