当我去运行我的应用程序时,我使用我的应用程序的主文件夹中的rails服务器启动服务器。当我使用127.0.0.1:3000查看我的应用程序主页时,它给了我这个错误(在Pages#home中的Sass :: SyntaxError);为什么我会收到此错误?
以下是我在命令行中的内容 :
Doesha@DOESHA-PC ~/Desktop/pinteresting (master)
$ rails server
=> Booting WEBrick
=> Rails 4.1.8 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0
.0.1 (--binding option)
=> Ctrl-C to shutdown server
[2015-01-22 08:07:32] INFO WEBrick 1.3.1
[2015-01-22 08:07:32] INFO ruby 2.1.5 (2014-11-13) [i386-mingw32]
[2015-01-22 08:07:33] INFO WEBrick::HTTPServer#start: pid=5848 port=3000
Started GET "/" for 127.0.0.1 at 2015-01-22 08:07:54 -0500
Processing by Rails::WelcomeController#index as HTML
Rendered c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/l
ib/rails/templates/rails/welcome/index.html.erb (45.0ms)
Completed 200 OK in 388ms (Views: 309.0ms | ActiveRecord: 0.0ms)
Started GET "/" for 127.0.0.1 at 2015-01-22 08:07:57 -0500
Processing by Rails::WelcomeController#index as HTML
Rendered c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/l
ib/rails/templates/rails/welcome/index.html.erb (0.0ms)
Completed 200 OK in 9ms (Views: 9.0ms | ActiveRecord: 0.0ms)
Started GET "/rails/info/properties" for 127.0.0.1 at 2015-01-22 08:08:02 -0500
Processing by Rails::InfoController#properties as */*
Rendered c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/l
ib/rails/templates/rails/info/properties.html.erb (0.0ms)
Completed 200 OK in 426ms (Views: 65.0ms | ActiveRecord: 62.0ms)
Started GET "/rails/info/properties" for 127.0.0.1 at 2015-01-22 08:08:27 -0500
Processing by Rails::InfoController#properties as */*
Rendered c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/l
ib/rails/templates/rails/info/properties.html.erb (1.0ms)
Completed 200 OK in 63ms (Views: 61.0ms | ActiveRecord: 0.0ms)
Started GET "/pages/home" for 127.0.0.1 at 2015-01-22 08:13:26 -0500
Processing by PagesController#home as HTML
Rendered pages/home.html.erb within layouts/application (2.0ms)
Completed 500 Internal Server Error in 234ms
ActionView::Template::Error (File to import not found or unreadable: bootstrap.
Load paths:
c:/Users/Doesha/Desktop/pinteresting/app/assets/images
c:/Users/Doesha/Desktop/pinteresting/app/assets/javascripts
c:/Users/Doesha/Desktop/pinteresting/app/assets/stylesheets
c:/Users/Doesha/Desktop/pinteresting/vendor/assets/javascripts
c:/Users/Doesha/Desktop/pinteresting/vendor/assets/stylesheets
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.2/lib/asse
ts/javascripts
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/jquery-rails-3.1.2/vendor
/assets/javascripts
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/coffee-rails-4.0.1/lib/as
sets/javascripts
(in c:/Users/Doesha/Desktop/pinteresting/app/assets/stylesheets/bootstrap_and_
customization.css.scss:1)):
2: <html>
3: <head>
4: <title>Pinteresting</title>
5: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolink
s-track' => true %>
6: <%= javascript_include_tag 'application', 'data-turbolinks-track' => tr
ue %>
7: <%= csrf_meta_tags %>
8: </head>
app/assets/stylesheets/bootstrap_and_customization.css.scss:1
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_ht
ml_erb___676133049_45098892'
Rendered c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8
/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (5.0ms)
Rendered c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8
/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
(3.0ms)
Rendered c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8
/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within
rescues/layout (141.0ms)
这是我的application.html.erb文件 :
<!DOCTYPE html>
<html>
<head>
<title>Pinteresting</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
这是我的网页/ home.html.erb文件 :
<h1>Pages#home</h1>
<p>Find me in app/views/pages/home.html.erb</p>
这是我的Gemfile :
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'bootstrap-sass'
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]
当我运行rails服务器并尝试在网络上本地加载我的应用主页 时,网页上显示了什么内容:
Sass::SyntaxError in Pages#home
Showing
c:/Users/Doesha/Desktop/pinteresting/app/views/layouts/application.html.erb where line #5 raised:
File to import not found or unreadable: bootstrap.
Load paths:
c:/Users/Doesha/Desktop/pinteresting/app/assets/images
c:/Users/Doesha/Desktop/pinteresting/app/assets/javascripts
c:/Users/Doesha/Desktop/pinteresting/app/assets/stylesheets
c:/Users/Doesha/Desktop/pinteresting/vendor/assets/javascripts
c:/Users/Doesha/Desktop/pinteresting/vendor/assets/stylesheets
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.2/lib/assets/javascripts
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/jquery-rails-3.1.2/vendor/assets/javascripts
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/coffee-rails-4.0.1/lib/assets/javascripts
(in c:/Users/Doesha/Desktop/pinteresting/app/assets/stylesheets/bootstrap_and_customization.css.scss:1)
Extracted source (around line #5):
2
3
4
5
6
7
8
<html>
<head>
<title>Pinteresting</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
Rails.root: c:/Users/Doesha/Desktop/pinteresting
Application Trace | Framework Trace | Full Trace
app/assets/stylesheets/bootstrap_and_customization.css.scss:1
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___676133049_45098892'
答案 0 :(得分:0)
尝试bootstrap-sass-rails而不是bootstrap-sass。它适合在资产管道中使用,因此您不必乱用导入bootstrap-sprockets。 https://github.com/yabawock/bootstrap-sass-rails
答案 1 :(得分:-1)
您是否从终端运行bundle install
然后重新启动服务器?如果是这样,我认为问题可能是application.css.scss文件中引用的apneadiving。
确保首先引导bootstrap-sprockets,如下所示:
application.css.scss
@import "bootstrap-sprockets";
@import "bootstrap";