2014-10-19 107 views
0

我想了解如何在rails应用程序中使用基础gem。我首先搭建了一个简单的待办事项应用程序,播种数据库并在我的本地服务器中运行,没有错误。接下来,我添加了基础宝石我的宝石文件:基金会zurb,html css

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

冉捆绑,然后跑去轨摹基础:安装

当我运行我的本地服务器我现在收到以下错误:

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(); });

回答

1

这是最新版本的问题sass gem(sass-rails gem需要)的sion,但它可以很容易地克服。

在你的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

一旦问题得到解决并合并到主分支中,随后会发布新版本的sass gem,并附带修复程序。一旦完成,您应该能够删除Gemfile中的附加行。然后只需要再次执行bundle update sass即可获得最新的sass gem版本。