在application.css中找不到// = require jquery.nouislider

时间:2014-06-07 11:00:41

标签: javascript css ruby-on-rails pipeline assets

我试图使用一些滑块宝石,我一直遇到同样的问题,

https://github.com/soycamo/jquery-nouislider-rails

我按照说明放入app / assets / javascript清单文件:

// = require jquery.nouislider

在app / assets / stylesheets清单文件中:

// = require jquery.nouislider

我也安装了宝石。但是我不断收到错误消息:

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

2 个答案:

答案 0 :(得分:1)

在app / assets / stylesheets / application.css中,它应该是

*= require jquery.nouislider

而不是

//= require jquery.nouislider

并尝试用;

替换Gemfile声明

gem 'jquery-nouislider-rails', '~> 4.0.1.1'指定版本并重新启动服务器

工作设置

我简单downloaded nonuislider here并将其添加到app / assets / javascripts文件夹中,然后在application.js中调用它,就像之前所做的那样,它工作正常。也许Gem有问题。

答案 1 :(得分:0)

不确定,但似乎你的宝石不是最新的。

你可以尝试使用noUiSlider的这个fork:

https://github.com/chug2k/nouislider-rails

或者这是Seiyria的滑块:

https://rubygems.org/gems/bootstrap-slider-rails/versions/6.0.17

快乐滑动: - )