这是我现在得到的错误:
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 :(得分:6)
Rails中的Gemfile中没有assets
组。从该组中删除所有资产gems。
答案 1 :(得分:1)
你正在使用铁路&gt; 4,默认情况下包含jquery而不添加gem。
jquery-uj也是如此。等等。
另外,我注意到你正在使用jquery-turbolinks gem。
根据GitHub page,您应按以下顺序创建application.js:
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//
// ... your other scripts here ...
//
//= require turbolinks
您的订单不同......
答案 2 :(得分:1)
在套件中的Javascripts文件夹中,页面底部将如下所示......
'//=require jquery'
'//=require jquery_ujs'
'//=require turbolinks'
'//=require_tree .'
在我的情况下,我的网站中没有任何jquery所以我采用了&#34; =&#34;出来,这解决了我的问题!看起来很漂亮我可能会加上!
'// require jquery'
'// require jquery_ujs'
'// require turbolinks'
'// require_tree .'
谢谢Chris Dunphy