Phusion error: undefined method `has?' for Sas

2019-06-20 11:11发布

问题:

I get the following error issued by Phusion when loading a web page:

There was an error while trying to load the gem 'compass-rails'.
Gem Load Error is: undefined method `has?' for Sass::Util:Module
Did you mean?  hash
               Hash
Backtrace for gem load error is:
/Volumes/Data/htdocs/zetcho/vendor/bundle/gems/compass-0.12.2/lib/compass/sass_extensions/functions/urls.rb:5:in `has?'

The code at the indicated location is:

module Compass::SassExtensions::Functions::Urls


def self.has?(base, instance_method)
  Sass::Util.has?(:instance_method, base, instance_method)
end

My gem file contains:

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.2'

# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.3.18'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'

# Use Compass for stylesheets
gem 'compass-rails'

# Use the Compass extension susy
gem "sprockets"
gem 'susy'

I've just created the Ruby on Rails site using Rails 5.1.2 and ruby 2.3.1. I have a much older site that works fine with the gem. Did I miss a step in the overall install or is this a bug with compass-rails?

I got the same error when I tried to add a controller:

rails generate controller home index

回答1:

After more digging around, I found a similar problem. I fixed this one by changing the gem file to:

gem 'compass-rails', github: 'Compass/compass-rails'

Then:

rm gemfile.lock
bundle


回答2:

It seems that the issue can be found in compass-rails 2.0.0. The version 3.0.2 seems to fix this issues. So a possible solution is :

# Gemfile
gem 'compass-rails', '~> 3.0.2'

Then bundle update compass-rails

This avoids targeting the compass-rails git master branch in favor of an actual release.