我正在尝试学习如何在Rails应用程序中使用基础gem。我首先搭建了一个简单的待办事项应用程序,为数据库添加了种子,然后在本地服务器上运行它而没有错误。接下来,我将基础gem添加到我的gem文件中:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0.beta2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.0.beta1'
# 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', '~> 4.0.0.beta2'
# 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 'sdoc', '~> 0.4.0', group: :doc
gem 'foundation-rails'
# 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 'debugger' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0.0.beta4'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
运行包,然后运行rails g Foundation:安装
当我运行本地服务器时,我现在收到以下错误:
NoMethodError in TodosController#index
undefined method `specificity' for [:not(.button)]:Array (in /todo_app/app/assets/stylesheets/foundation_and_overrides.scss)
Extracted source (around line #96):
94
95
96
97
98
99
arr.each do |m|
next if m.is_a?(String)
spec = m.specificity
if spec.is_a?(Range)
min += spec.begin
max += spec.end
感谢您的时间和帮助。
我的application.css文件:
*
* 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 vendor/assets/stylesheets of plugins, if any, 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_tree .
*= require_self
*= require foundation_and_overrides
*/
我的application.js文件:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require foundation
//= require turbolinks
//= require_tree .
$(function(){ $(document).foundation(); });
最佳答案
这是最新版本的sass gem(sass-rails gem要求的)的问题,但可以轻松克服。
在您的Gemfile中,在您的sass-rails
规范下面添加以下行:gem 'sass', '3.4.5'
如果正在使用捆绑程序,请通过运行bundle
更新捆绑包。如果它抱怨sass gem被锁定到3.4.6版本,则只需运行bundle update sass
。完成后,您应该会很好。
请注意,这仅是临时措施,直到更新了sass gem并实施了修复程序为止。
您可以在https://github.com/sass/sass/issues/1476处查看并关注该问题。
一旦问题解决并合并到master分支中,之后将发布新版本的sass gem,包括修复程序。完成后,您应该能够删除Gemfile中的该附加行。然后,只需再次执行bundle update sass
即可与最新的sass gem版本保持最新。
关于css - 基金会zurb,HTML CSS,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26455355/