我试图将Bootstrap包含到我的示例Web项目中(第5章Hartl的Rails教程)并发生错误:
Sprockets :: StaticPages中的CircularDependencyError #home
显示/home/ror/rubys/sample_app/app/views/layouts/application.html.erb,其中第5行>提出:
/home/ror/rubys/sample_app/app/assets/stylesheets/application.css已被要求
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", media: "all",
"data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
我创建app / assets / stylesheets / custom.css.scss并添加@import&#34; bootstrap&#34 ;;那里 并将config.assets.precompile + =%w(* .png * .jpg * .jpeg * .gif)添加到config / application.rb
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
gem 'bootstrap-sass', '2.3.2.0'
gem 'sprockets', '2.11.0'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
gem 'guard-rspec', '2.5.0'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
# Linux: раскомментируйте эти строки.
gem 'libnotify', '0.8.0'
end
gem 'sass-rails', '4.0.1'
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
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<<%= stylesheet_link_tag "application", media: "all",
"data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<header class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
<%= link_to "sample app", '#', id: "logo" %>
<nav>
<ul class="nav pull-right">
<li><%= link_to "Home", '#' %></li>
<li><%= link_to "Help", '#' %></li>
<li><%= link_to "Sign in", '#' %></li>
</ul>
</nav>
</div>
</div>
</header>
<div class="container">
<%= yield %>
</div>
</body>
</html>
答案 0 :(得分:0)
尝试删除app / assets / stylesheets / application.css。
您的application.html.rb文件中也有拼写错误。额外的&#39;&#39;加入了。
<<%= stylesheet_link_tag "application", media: "all",
"data-turbolinks-track" => true %>
应该是
<%= stylesheet_link_tag "application", media: "all",
"data-turbolinks-track" => true %>
感谢。