Rails 4.1.4:/ admin中的Sprockets :: FileNotFound找不到文件'jquery.ui.all'

时间:2014-07-15 20:03:47

标签: ruby-on-rails jquery-ui sprockets

虽然,类似的问题,但提出的解决方案都没有奏效。

在从Rails 4.0.0升级到Rails 4.1.4之前,一切正常。作为调试的一部分,我删除了Gemfile.lock并使用“bundle install”重新生成

Rails 4.1.4 Ruby 2.0

由于2.12.x中的问题无法使用Rails 4.1.4,链轮限制在2.11.0。 sass-rails限制在4.0.2。作为限制链轮版本的同一问题的一部分。

的Gemfile:

source 'https://rubygems.org'

gem 'rails', '= 4.1.4'
gem 'sass-rails', '4.0.2'
gem 'haml-rails'
gem 'coffee-rails'

gem 'jquery-rails'
gem 'jquery-ui-rails'

gem 'uglifier'
gem 'therubyracer'
gem 'turbolinks'

group :development do
  gem 'thin'
  gem 'erb2haml'

  gem 'capistrano'
  gem 'rvm-capistrano'
  gem 'rspec-rails'
end
gem 'jbuilder'

gem 'mysql2', '~> 0.3.12b5'

gem "sprockets", "2.11.0"
gem 'better_errors', group: :development
gem 'sprockets_better_errors', group: :development
gem 'binding_of_caller', group: :development
gem 'quiet_assets', group: [:development, :test]

# Lots more gems omitted...

摘自Gemfile.lock:

jquery-rails (3.1.1)
  railties (>= 3.0, < 5.0)
  thor (>= 0.14, < 2.0)
jquery-ui-rails (5.0.0)
  railties (>= 3.2.16)

包含jquery.ui.all行的CoffeeScript:

#= require active_admin/base
#= require jquery
#= require jquery_ujs
#= require jquery.ui.all

“捆绑exec rake资产:预编译”中的实际错误:

03:58:54:website >> bundle exec rake assets:precompile
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/actionpack-4.1.4/lib/action_dispatch/http/mime_type.rb:163: warning: already initialized constant Mime::VCF
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/actionpack-4.1.4/lib/action_dispatch/http/mime_type.rb:163: warning: previous definition of VCF was here
rake aborted!
Sprockets::FileNotFound: couldn't find file 'jquery.ui.all'
  (in /Users/mwlang/projects/clients/law/site/website/app/assets/javascripts/active_admin.js.coffee:4)
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/context.rb:106:in `resolve'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/context.rb:146:in `require_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:217:in `process_require_directive'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:167:in `block in process_directives'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:165:in `each'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:165:in `process_directives'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:99:in `evaluate'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/context.rb:197:in `block in evaluate'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/context.rb:194:in `each'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/context.rb:194:in `evaluate'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/processed_asset.rb:12:in `initialize'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/base.rb:374:in `new'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/base.rb:374:in `block in build_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/base.rb:395:in `circular_call_protection'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/base.rb:373:in `build_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/caching.rb:58:in `cache_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/bundled_asset.rb:16:in `initialize'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `new'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `build_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/caching.rb:58:in `cache_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:211:in `block in find_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:257:in `benchmark'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:210:in `find_asset'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:119:in `block in compile'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `each'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `compile'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-rails-2.0.1/lib/sprockets/rails/task.rb:60:in `block (3 levels) in define'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-2.11.0/lib/rake/sprocketstask.rb:146:in `with_logger'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/gems/sprockets-rails-2.0.1/lib/sprockets/rails/task.rb:59:in `block (2 levels) in define'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/bin/ruby_noexec_wrapper:14:in `eval'
/Users/mwlang/.rvm/gems/ruby-2.0.0-p451/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => assets:precompile

3 个答案:

答案 0 :(得分:7)

在深入研究之后,结果表明在项目中包含jquery-ui-rails的语法已经改变了javascript和样式表! Rails 4.1.x的工作解决方案是:

在你的Gemfile中,只需包含gem:

gem 'jquery-ui-rails'

您无需指定源或分支。

而不是旧的方式(对于一切):

#= require jquery.ui.all

您现在应该使用:

#= require jquery-ui

注意&#34;。&#34;成为&#34; - &#34;

如果您想要包含特定组件,那么它也会发生变化。而不是:

#= require jquery.ui.sortable

现在:

#= require jquery-ui/sortable

答案 1 :(得分:2)

我遇到了一个非常类似的问题,这里的解决方案对我有用:Heroku Rails 4-- FileNotFound jquery.ui.all

在宝石文件中,更改行

gem 'jquery-ui-rails'

gem 'jquery-ui-rails', github: 'joliss/jquery-ui-rails', branch: 'rails-4.0.2'

然后运行

bundle update

答案 2 :(得分:0)

除了@Michael Lang的回答,我还要做另外一件事让它发挥作用:

//= require jquery-ui必须遵循//= require jquery_ujs

所以它看起来像这样:

//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require_tree .