Phusion error: undefined method `has?' for Sass::Util:Module - ruby-on-rails

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

Related

How can I use SQLite 3 with RubyOnRails?

First, I'm bad at english, so I can't give a lot of details.. I've been trying to create a website using ruby on rails:
rails new azer
rails generate controller pages home
The last command doesn't work and there's an error occuring during generating:
/home/esteban/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/connection_specification.rb:177: in
'rescue in spec': Specified 'sqlite3' for database adapter, but the
gem is not loaded. Add gem 'sqlite3' to your Gemfile (and ensure its
version is at the minimum required by ActiveRecord).(Gem::LoadError)
So I opened my gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.10'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
...
...
I'm unsure what might be the error cause thus I don't know how to proceed.
Versions:
Ruby 2.4.4
Rails 4.2.10
SQLite3 1.4.1.
EDIT : Thanks for your help everyone, I appreciate it ! I just tried to reinstall rails and it worked
It seems version 1.4.x won't work with Rails 4. Install version 1.3.13 instead:
Unisntall version 1.4.1:
gem uninstall sqlite3 -v1.4.1
Modify Gemfile:
gem 'sqlite3', '~> 1.3.13'
And run bundle install.

What is the easy way to upgrade rails application?

I am working on a very old rails project. The gemfile is like this:
source 'http://rubygems.org'
gem 'rails', '2.3.17'
gem 'rake', '0.8.7'
gem 'rdoc', '3.6.1'
gem 'mysql', '2.8.1'
gem 'roo', '1.9.7'
gem 'rubyzip', '0.9.4'
gem 'pdf-writer', '1.1.8'
gem 'prawn', '0.12.0'
gem 'sendmail'
gem 'htmldoc', '0.2.3'
The ruby version is 1.8.7
What is the easy way to upgrade this rails app ? Can I just change the version of each gem to the latest one and expect it will work fine?
There is no easy way. Before You start upgrade you must add tests to be sure that application will still work after upgrade.
Then I recommend to change gem description to following syntax:
gem 'mysql', '~> 2.8.1' it tells bundler to update only last number of version of gem.
Then repeat following step
change rails version to next
bundle update rails
corrected conflicted gem version by hands
bundle update

Unicorn not happy with my rack version?

I have been repeating this tutorial for weeks now:
https://www.digitalocean.com/community/articles/how-to-1-click-install-ruby-on-rails-on-ubuntu-12-10-with-digitalocean
Here are the specifics of my project:
I am using Mongoid with database.yml production set to my tested and working Droplet (DigitalOcean VPS) running MongoDB.
My gem file is here, I am new to Rails and am not quite sure if it's set up right, so I just moved them all to assets hoping Unicorn might serve these gems for me?
source 'https://rubygems.org'
gem 'rails', '3.2.14'
# 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'
gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"
gem 'redcarpet', '1.17.2'
gem 'uglifier', '>= 1.0.3'
gem "will_paginate_mongoid"
gem 'will_paginate', '~> 3.0.5'
gem 'will_paginate-bootstrap'
gem 'devise'
gem 'jquery-rails'
gem "mongoid", "~> 3.0.0"
end
Here's what I did:
I used DigitalOcean's 1 click installer. Then I used FileZilla to SFTP into the credentials they provided me with. I deleted all the files in /home/rails and put my new files in from my project. Then I executed bundle install, and restarted the unicorn service. In the tutorial I had seen I can track the log of unicorn, so I executed this: tail -f /home/unicorn/log/unicorn.log
Here is the output which concerns me:
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup': You have already activated rack 1.5.2, but your Gemfile requires rack 1.4.5. Using bundle exec may solve this. (Gem::LoadError)
I saw some other solutions to this, all failed. Here are the solutions I tried:
Deleting my Gemfile.lock, and re bundle installing it. Going into the file and removing where it said rack. Running bundle install --binstubs. Restarting the unicorn service with bundle exec before it. The error remains the same.
I've had many different errors before, but I feel this is the closest I have gotten. If someone could explain this to me (I'm new to Rails and would like a thorough explanation) and possibly help me fix the error that would be fantastic and end this frustration.
Just a wild guess
gem "rack", "~> 1.4.5"
May work for you, then of course bundle install afterwards.
This solves the problem:
gem uninstall rack -v 1.5.2
Possibly reload your Ubuntu installation from the DigitalOcean control panel, then try and install Ruby on Rails with Apache and Passenger?
Install RoR
Install Passenger (skip to passenger installation)
You will have errors when first creating your site with rails new as it will try and use SQL when it won't be installed, if you wish to use MongoDB

Ruby on Rails: BlueCloth gem cannot work in production when deployed to heroku

I'm trying to use the BlueCloth gem in order to parse some markdown for my rails app. I added it to my gem file:
gem 'BlueCloth'
In my .html.erb views I user the code
<%= BlueCloth.new(post.content).to_html.html_safe %>
To render the markdown as html. This works completely fine in my local dev environment, but when I push to heroku, even after running bundle install and restarting the app, accessing the app generates internal server errors.
I get the following error in the logs:
ActionView::Template::Error (uninitialized constant ActionView::CompiledTemplates::BlueCloth):
I include BlueCloth in the gem file:
source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'pg'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'devise'
gem 'BlueCloth'
I have also run the command bundle install via the heroku command line.
Thanks for the help!
It looks like your manually requiring files. It might be easier for you if you use bundler to require everything for you and then you dont have to add require to any other .rb file. Its very simple to do this. Depending on your Rails version, here are two links that should help you out:
Rails 2.3
Rails 3
The issue was that I was using the old version of the BlueCloth gem.
The old gem is called BlueCloth and the new one is called bluecloth
Changing the line in my gem file:
gem 'BlueCloth'
To:
gem `bluecloth`
Fixed it.
Thanks.

Ruby on Rails: Getting NameError whenever delayed_job gem is used

Totally stumped on this one and hoping some RoR expert can help.
Hitting this strange error where if I install the delayed_job gem, my site (development env) just stops working. All controllers and methods will show a NameError exception:
NameError in ProductsController#show
cannot remove Object::ClassMethods
I know it's the delayed_job gem because if I uninstall it or comment it out, restart the server, the errors go away.
My gemfile looks like the following:
source 'http://rubygems.org'
gem 'rails', '3.0.10'
# Bundle edge Rails instead:
gem 'delayed_job', "2.1.4"
gem 'sqlite3'
gem 'faker', '0.3.1'
gem 'webrat', '0.7.1'
gem 'will_paginate', '3.0.pre2'
gem "amazon_product", "3.0.0.pre.2" #http://code.papercavalier.com/amazon_product/
gem "curb"
gem "authlogic"
gem "omniauth", ">=0.2.6"
gem "faraday"#, ">=0.7.4"
gem "fb_graph"
gem "twitter"#, "~> 1.7.1"
I am using Ruby 1.8.7 and Rails 3.0.10.
If you have any idea what might be the problem, please help :)
I figured out what the culprit was. In my controllers, I was including "#include ActionView::Helpers::TextHelper" at the top so I can use the truncate function. Including that apparently cause some naming conflicts withint delayed_job. Removing the include solved my problem.

Resources