2014-08-29 88 views
2

這是錯誤,現在我得到:找不到文件 'jQuery的'

Started GET "/" for 127.0.0.1 at 2014-08-29 06:37:21 -0500 
    ActiveRecord::SchemaMigration Load (0.9ms) SELECT "schema_migrations".* FROM "schema_migrations" 
Processing by PostsController#index as HTML 
    Post Load (0.8ms) SELECT "posts".* FROM "posts" ORDER BY created_at desc 
    Rendered shared/_color.html.erb (0.6ms) 
    Rendered shared/_color.html.erb (0.1ms) 
    Rendered shared/_color.html.erb (0.3ms) 
    Rendered posts/index.html.erb within layouts/application (47.4ms) 
Completed 500 Internal Server Error in 264ms 

Sprockets::FileNotFound - couldn't find file 'jquery' 
    (in /app/assets/javascripts/application.js:13): 

這是我application.js

//= require jquery <--- This is Line 13 
//= require jquery_ujs 
//= require jquery-ui 
//= require jquery.turbolinks 
//= require bootstrap 
//= require social-share-button 
//= require turbolinks 
//= require_tree . 

這是我Gemfile

source 'https://rubygems.org' 

gem 'rails', '4.1.1' 

group :assets do 
    gem 'sass-rails', '~> 4.0.3' 
    gem 'uglifier', '>= 1.3.0' 
    gem 'coffee-rails', '~> 4.0.0' 
    gem "font-awesome-rails" 
    gem 'bootstrap-sass', '~> 3.2.0' 
    gem 'autoprefixer-rails' 
    gem 'jquery-rails' 
    gem 'jquery-turbolinks' 
    gem 'turbolinks' 
end 

group :development do 
    gem 'annotate', github: 'ctran/annotate_models' 
    gem 'sextant' 
    gem "quiet_assets", ">= 1.0.2" 
    gem 'better_errors', '~> 1.1.0' 
    gem 'binding_of_caller', '~> 0.7.2' 
    gem 'meta_request' 
    gem 'execjs' 
    gem 'therubyracer' 
    gem "letter_opener" 
    gem 'bullet' 
    gem 'rack-mini-profiler'  
    gem 'guard-rails' 
    gem 'rb-fchange', :require => false 
    gem 'rb-fsevent', :require => false 
    gem 'rb-inotify', :require => false 
    gem 'guard-livereload', '~> 2.3.0', :require => false 
    gem 'rack-livereload', '~> 0.3.15' 
    gem 'spring' 
end 

group :production do 
    gem 'rails_12factor' 
end 

gem 'jbuilder', '~> 2.0' 
gem 'sdoc', '~> 0.4.0',   group: :doc 
gem 'devise', '~> 3.2.4' 
gem 'thin' 
gem 'pg' 
gem 'cancancan', '~> 1.8.2' 
gem 'rolify' 
gem 'rmagick', :require => 'RMagick' 
gem "mini_magick" 
gem 'carrierwave', '~> 0.10.0' 
gem "fog", "~> 1.3.1" 
gem 'figaro', '~> 0.7.0' 
gem 'geocoder', '~> 1.2.2' 
gem 'social-share-button', '~> 0.1.6' 
gem 'ancestry', '~> 2.1.0' 
gem "simple_form" 

這是我的application.html.erb

<!DOCTYPE html> 
<html> 
<head> 
    <title>My Site</title> 
    <!-- Style sheet --> 
    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> 

    <!-- Javascript --> 
    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 
    <!-- Fonts --> 
    <link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro%3A400%2C400italic%2C700" rel="stylesheet"> 
    <link href="http://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet"> 

    <!-- MISC --> 
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"> 
    <%= csrf_meta_tags %> 
    <%= yield :head %> 
</head> 
<body> 

<%= render partial: "shared/nav" %> 
    <% if notice %> <div class="alert alert-info"> <%= notice %> </div> <% end %> 
    <% if alert %> <div class="alert alert-warning"> <%= alert %> </div> <% end %> 
<%= yield %> 

</body> 
</html> 

什麼可能導致此錯誤?

+0

嘗試「從資產阻止它可以創建issue.' – 2014-08-29 11:57:21

+0

@marcamillion我真誠道歉jQuery的rails'',因爲我不小心撞到了‘刪除'寶石下來投票’按鈕這個問題。我建議的解決方法是糾正錯誤,並啓用「投票」按鈕,讓您對自己的帖子進行一些簡單的修改,這樣我就可以撤消錯誤了。我想爲您提供這個問題的讚賞,而不是負面影響。謝謝,我的道歉! – 2016-08-15 17:36:09

回答

1

您使用鐵路> 4,讓jQuery是在默認情況下不添加寶石到它包括在內。

jquery-uj也是如此。

另外,我注意到,你使用jQuery的turbolinks寶石。資產產生內

//= require jquery 
//= require jquery.turbolinks 
//= require jquery_ujs 
// 
// ... your other scripts here ... 
// 
//= require turbolinks 

和您的訂單是不同的...

+0

我試圖刪除'jquery-rails'寶石,它不起作用。它抱怨application.js中的'require jquery'。 – marcamillion 2014-08-29 12:28:33

1

在你的Javascript文件夾,底部:

按照GitHub page,應該按以下順序創建您的application.js該頁面看起來就像這樣......

'//=require jquery' 
'//=require jquery_ujs' 
'//=require turbolinks' 
'//=require_tree .' 

就我而言,我沒有任何的jQuery在我的地盤,所以我採取了「=」出來,這個固定我的問題!看起來很美,我可能會添加

'// require jquery' 
'// require jquery_ujs' 
'// require turbolinks' 
'// require_tree .' 

感謝克里斯·鄧菲