How to Installing compas with rails 4? - ruby-on-rails

I am building a rails application and I want to install compass.
I put this on my Gemfile
gem "compass-rails", "~> 2.0.alpha.0"
I am trying to import the file
#import "compass"
and it seems that is not founding the file.
What more should I do except from the gem installation ?

Related

Phusion error: undefined method `has?' for Sass::Util:Module

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
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
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.
I came here having the same issue with a grunt compiling issue trying to use Compass/Sass, if this might help someone, my issue was caused because I had an updated version of Sass (sass-3.7.4) that was higher that the max-version compatible with compass, I uninstalled sass:
gem uninstall sass
Which in turn uninstalled compass, and reinstalled compass letting it choose the right version, and problem solved.
gem install compass

Cannot install gem march_hare

I tried adding this to my Gemfile:
gem 'march_hare', '~> 2.22'
Using bundle install I got this message:
Could not find gem 'march_hare (~> 2.22)' in any of the gem sources listed in
your Gemfile or available on this machine.
On the topmost line in my Gemfile, I have this :
source 'https://rubygems.org'
When I manually visit the rubygems and I m able to find this gem here :
https://rubygems.org/gems/march_hare
How do I install this gem? I don't understand what is happening.
It doesn't work with any jRuby older than 9.0, this was a miss on my part

Using susy in Rails

I am using Rails 4.2.5. And I want to use susy.
I've installed some gems required,
gem 'susy'
gem 'compass-rails', '~> 2.0.0'
gem 'compass-susy-plugin'
gem 'sass-rails', '~> 5.0.0'
And in config/application.rb, I've added
require 'susy'
In application.scss
#import "susy";
But I failed to import susy in my scss file. When I give the command sass --watch application.scss:application.css, it shows error application.scss (Line 1: File to import not found or unreadable: susy.).
I may found the answer myself.
Actually, there's no need to convert scss file to css file since the gems we've installed will do that job for us.
By the way, upgrading the compass-rails gem to master may avoid some problem. See this issue.

New user trying to install a Ruby Gem (bootstrap)

I am new to rails and I'm trying to create a new project and add the bootstrap 3 ruby Gem (https://rubygems.org/gems/bootstrap-sass) and I can't work out what I'm doing wrong.
I create the new application:
rails new demoapp
I add the following line to the Gemfile
gem 'bootstrap-sass', '~> 3.1.1'
I bundle it
bundle install
I run it
rails server
However no bootstrap is present on my site and I can't use bootstrap css, what am I doing wrong?
You need to add boot strap to the assets file.
Import Bootstrap into a Sass file (for example, application.css.scss)
to get all of Bootstrap's styles, mixins and variables!
From https://github.com/twbs/bootstrap-sass
Basically, add #import "bootstrap"; to your application.css.scss file...
You need to add the gem inside the GemFile like
gem 'bootstrap-sass'
And then run the following command
bundle install
No need to run
gem install bootstrap-sass

Compass plugin Susy not found

I'm running a Rails 4 app and trying to get compass and susy running. I'm getting the following error:
File to import not found or unreadable: susy.
My gemfile group:
group :assets do
gem 'sass-rails', '~> 4.0.0.beta1'
gem 'compass-rails'
gem 'susy'
...
end
The only CSS line I have (_base.sass)
#import susy
I've run Bundle Install, and my app is using:
Using compass-rails (1.0.3)
Using susy (1.0.7)
Completely lost. I don't have a config.rb file for compass, but from what I gather it isn't necessary after like Rails 3.1/3.2. Any ideas?
You can found the solution in the compass-rails gem documentation:
You have to add the gem compass-susy-plugin instead of susy, like this:
# Gemfile
…
gem 'compass-rails'
gem 'compass-susy-plugin'
…
If you are using Rails 4 do not use group :asset, it has been removed, simply add the previous lines to the Gemfile.
Then run:
$ bundle
$ bundle exec compass install susy
These previous lines will generate files that require susy for you.
And finally add this to your application.rb:
# config/application.rb
config.compass.require "susy"

Resources