2014-10-19 166 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版本。