我试图效仿Michael Hartl的Ruby on Rails Tutorial 3rd Edition,稍微修改一下Gemfile和Sassy CSS文件。当我尝试在我的custom.css.scss中使用引导程序变量和混合来显示引导程序驱动的验证错误时,我得到了“未定义的”错误。
我已经确认该变量存在于我的{"bundle show bootstrap-sass“path}/assets/stylesheets/bootstrap/_variables.scss中,它似乎在抛出错误之前没有查找该文件。
请让我知道如何解决这个问题。非常感谢!
这是我的Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use pg as the database for Active Record
gem 'pg', '0.18.1'
gem 'bcrypt', '3.1.7'
gem 'faker', '1.4.2'
gem 'carrierwave', '0.10.0'
gem 'mini_magick', '3.8.0'
gem 'fog', '1.23.0'
gem 'will_paginate', '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass', '3.3.3'
# Use SCSS for stylesheets
gem 'sass-rails', '5.0.1'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '2.7.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '4.1.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', '4.0.3'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks', '2.5.3'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '2.2.6'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '0.4.1', 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
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', '3.5.1'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '2.0.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', '1.2.0'
end
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
end
group :production do
gem 'rails_12factor', '0.0.3'
gem 'puma', '2.11.1'
end这是我的application.css.scss
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_self
*/
@import "bootstrap-sprockets";
@import "bootstrap";
@import "custom.css.scss"这是我的custom.css.scss
#error_explanation {
color: red;
ul {
color: red;
margin: 0 0 30px 0;
}
}
.field_with_errors {
@extend .has‐error;
.form‐control {
color: $state‐danger‐text;
}
}发布于 2015-03-07 21:25:43
20个小时后,我终于发现只有当我将教程中的代码复制到sublime text 2中时才会出现错误。我自己编写了每一行相关代码,现在工作正常,没有错误。可能是某个奇怪的角色在我抄袭的时候偷偷进来了。很奇怪!
https://stackoverflow.com/questions/28903777
复制相似问题