我试图使用一些滑块宝石,但我不断碰到同样的问题,
https://github.com/soycamo/jquery-nouislider-rails
我按照说明放入app / assets / javascript清单文件:
// =需要jquery.nouislider
在app / assets / stylesheets清单文件中:
// =需要jquery.nouislider
我还安装了gem。 但是,我不断收到错误消息,指出:
Showing /home/ubuntu/foodin/app/views/layouts/application.html.erb where line #8 raised:
couldn't find file 'jquery.nouislider'
(in /home/ubuntu/foodin/app/assets/stylesheets/application.css:16)
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
我认为这可能与资产管道有关,但我不确定。 有任何想法吗? 谢谢您的帮助!
编辑:这是我的development.rb配置文件,以防与其相关联:
Foodin::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
#NEW: Added for Devise
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
#New:Added for development
config.serve_static_assets = false
end
在app / assets / stylesheets / application.css中应该是
*= require jquery.nouislider
并不是
//= require jquery.nouislider
并尝试将Gemfile声明替换为;
gem 'jquery-nouislider-rails', '~> 4.0.1.1'
指定版本并重新启动服务器
工作设置
我在这里简单地下载了nonuislider ,并将其添加到app / assets / javascripts文件夹中,然后像以前一样在application.js中对其进行了调用,并且可以正常工作。 宝石也许有问题。
不确定,但您的宝石似乎不是最新的。
您可以为noUiSlider尝试使用此fork:
https://github.com/chug2k/nouislider-rails
或针对Seiyria的Slider:
https://rubygems.org/gems/bootstrap-slider-rails/versions/6.0.17
快乐滑:-)