我正在尝试向我的应用程序添加一个jquery ui datepicker并收到此错误 找不到文件'jquery-ui' (在/home/sumyvps/rails_projects/Expense_book/app/assets/javascripts/application.js:18)
我在许多链接中尝试过说明但没有得到解决方案。
我的Gemfile是
source 'https://rubygems.org'
ruby '1.9.3'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.8'
gem 'bootstrap-sass', '3.2.0.0'
gem 'sprockets', '2.11.0'
gem 'bcrypt-ruby', '3.1.2'
gem 'will_paginate', '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'jquery-ui-rails', '~> 4.2.1'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.3'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
application.css文件如下
*= require_self
*= require_tree .
*= require jquery.ui.datepicker
*= require jquery.ui.core
*= require jquery.ui.theme
application.js是
//= require turbolinks
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .
//= require jquery-ui
//= require jquery.ui.datepicker
有人请帮忙......
答案 0 :(得分:0)
当您使用gem 'jquery-ui-rails', '~> 4.2.1'
时,您必须在js中包含//= require jquery.ui.all
,在css中包含*= require jquery.ui.all
而不是//= require jquery.ui
& *= require jquery.ui
因为//= require jquery.ui
&在*= require jquery.ui
4.x.x版本中不存在'jquery-ui-rails', '~> 5.0.0'
后,'jquery-ui-rails'
出现{{1}}。
查看更多文档更改here for 4.x.x和here for 5.x.x