【问题标题】:compass install bootstrap -> NoMethodError on line ["32"] ... sass-rails-3.2.6/lib/sass/rails/helpers.rb: undefined method `[]' for nil:NilClasscompass install bootstrap -> NoMethodError on line ["32"] ... sass-rails-3.2.6/lib/sass/rails/helpers.rb: undefined method `[]' for nil:NilClass
【发布时间】:2013-04-16 01:30:27
【问题描述】:

运行此命令后

compass install bootstrap

我收到这条消息:

identical sass/styles.scss

...

identical javascripts/bootstrap-typeahead.js
NoMethodError on line ["32"] of /Users/xxx/.rvm/gems/ruby-1.9.3-p327@favy/gems/sass-rails-3.2.6/lib/sass/rails/helpers.rb: undefined method `[]' for nil:NilClass
Run with --trace to see the full backtrace

在 /Users/xxx/.rvm/gems/ruby-1.9.3-p327@favy/gems/sass-rails-3.2.6/lib/sass/rails/helpers.rb 中

 31     def resolver
 32       options[:custom][:resolver]
 33     end

我尝试了一种解决方法 -> https://gist.github.com/castus/4044953

def resolver
  if ::Rails::env == "production"
    options[:custom][:resolver]
  else
    Resolver.new(CompassRails.context)
  end
end

& 仍然没有运气:)

我的 config/compass.rb 中有这些东西

require 'bootstrap-sass'

还有我的 Gemfile

source 'http://rubygems.org'

gem "paperclip"
gem 'bootstrap-sass', '~> 2.3.1.0'
gem 'compass-rails'
gem 'bootswatch-rails'

gem 'gmaps4rails'

gem 'rails', '3.2.13'
gem 'activerecord-postgresql-adapter'
gem 'devise'
gem 'sass-rails', '~> 3.2.3'
gem "haml"
gem "haml-rails"

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

【问题讨论】:

    标签: ruby-on-rails twitter-bootstrap compass-sass bootstrap-sass


    【解决方案1】:

    如果您使用 Rails 和 Bootstrap-sass,则根本不需要“指南针”。 Compass 适用于不使用 Rails 的网站。

    以下是安装和引导 sass 的步骤

    1. 将其添加到 Gemfile 和 bundle install

    2. 将 application.css 重命名为 application.css.scss

    3. 把application.css.scss中的所有cmets都去掉,留空

    4. 添加@import bootstrap

    你已经完成了!将其视为普通的 css 文件并使用 @import 做任何你喜欢的事情。但没有更多的require 发表评论!

    【讨论】:

    • 谢谢 :) 我只是想确认一下。安装 Bootstrap-sass 后我可以使用所有这些东西 (compass-style.org/reference/compass) 吗?
    • @whitesiroi,你提到的是 Compass 的 CSS 框架。你已经有了一个 CSS 框架——Twitter 引导程序。两个一起使用是不必要的,并且会产生冲突。
    猜你喜欢
    • 2014-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-12
    • 2020-09-24
    • 2017-07-04
    • 1970-01-01
    • 2013-08-31
    相关资源
    最近更新 更多