Rails: Requiring "RMagick" is deprecated. Use "rmagick" instead.FactoryGirl - ruby-on-rails

When I create an object via FactoryGirl and Faker, shell show me an error
[1] pry(main)> FactoryGirl.create(:company)
[DEPRECATION] requiring "RMagick" is deprecated. Use "rmagick" instead
but when I create object in development db - it's ok
there is factory
factory :company do
title Faker::Company.name
image Faker::Avatar.image("my-own-slug", "200x200")
end
how fix?

This is most certainly dues to CarrierWave when the execution comes to your line image Faker::Avatar.image("my-own-slug", "200x200").
There is an issue on CarrierWave which is closed now and the fix is merged. Either you include the github commit in your GemFile, or you wait for the next gem release.

First, most people will want to include rmagick in their bundle like this:
gem 'rmagick', require: false
Second, rmagick 2.15.0 was just released. (Find your version with bundle list.) Upgrade the gem to version 2.15.0 with bundle update.
At this point you may still get the error as a pull request to remove it is on github but has not been merged yet.

This is very late however it might help someone:
gem 'carrierwave', :github => 'satoruk/carrierwave' , :ref => '43179f94d6a4e62f69e812f5082d6447c9138480'
gem 'rmagick', require: false
This should give you the version with rmagick fixed. I am not sure why they don't merge it to the master.
Hope it helps.

If you are writing the following in Gemfile:
gem 'rmagick', :require => 'RMagick'
try rewrite as follows:
gem 'rmagick'
https://github.com/gemhome/rmagick#installing-via-bundler

Just update your carrierwave gem and that should do.
bundle update carrierwave

I had this same challenge when upgrading a Rails 5 app to Rails 6
Here's how I fixed it:
First, I added the most recent version of the rmagick gem to the Gemfile. As of this writing it is rmagick 4.2:
gem 'rmagick', '~> 4.2'
Next, I checked for the files where rmagick has been required. I modified the file below from:
class Admin::FormPrecedentsController < Admin::BaseController
require 'RMagick'
end
to this:
class Admin::FormPrecedentsController < Admin::BaseController
require 'rmagick'
end
That's all.
I hope this helps

If you are using Carrierwave gem you had to try downgrading the version to 0.7.0, add on your gemfile 'carrierwave', '0.7.0' and then run on the console 'bundle update carrierwave'

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

alternative for github : <repo-name> in gem file

I am trying to build the docrails in my system. When I clone the repo and do bundle install as the guides say.
I get the following error
You passed :github as an option for gem 'rails/active_record_deprecated_finders'
, but it is invalid.
Entry in gemfile looks like this:
gem 'rails/active_record_deprecated_finders', github: 'rails/active_record_deprecated_finders'
To avoid that what I am doing is commenting the rest of the line like this:
gem 'rails/active_record_deprecated_finders'#, github: 'rails/active_record_deprecated_finders'
Then it foregoes that and the next problem arrives with the error message saying:
Could not find gem 'active_record_deprecated_finders (>= 0) x86-mingw32' in any
of the gem sources listed in your Gemfile.
Environment specs:
Bundler version 1.0.21
Rails 3.2.3
Win7 64bit
Question
I dont know why its looking for x86 when my System is 64bit.Is there any work around for this? or its a bug?
If gem file couldn't accept github: as parameter why is it there in the first place?
Please let me know if there are any workarounds to this problem
The :github option is just shorthand for a longer :git option:
gem :foo, :github => 'rails/foo'
Is just short for
gem :foo, :git => 'git://github.com/rails/foo.git'
This is new in bundler 1.1 which is why it doesn't work on your setup. You could rewrite the gemfile but it would probably be easier to update bundler. In addition bundler 1.1 is a lot faster than 1.0

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.

Launching RoR server for an existing app gives error

I just made my first setup of RoR, and creating a new application works fine. But when I want to run the rails server I get the following error:
C:/Ruby192/lib/ruby/gems/1.9.1/gems/delayed_job-2.1.3/lib/delayed/yaml_ext.rb:30:in 'remove_method': method 'to_yaml' not defined in Class (NameError)
I ran the "bundle install" in the app directory and installed all the necessary files (with some problems however, but I excluded the gems with problems in the gemfile) and the last bundle install said that I have successfully installed all the needed packs.
I'm lost and I can't find a similar error on the internet. Can you help me?
EDIT: I forgot to mention that I'm not having a problem with a new application. It's running an existing one (that I didn't build, but works fine for others) that the error is related to. Here's the gemfile for that app:
source 'http://rubygems.org'
gem 'rails', '3.0.3'
gem 'mysql'
gem "haml", ">= 3.0.0"
gem "haml-rails"
gem 'simple_form'
gem 'delayed_job'
#gem 'auto_crawlers'
gem 'will_paginate', '~> 3.0.beta'
group :test do
gem 'factory_girl_rails'
gem 'mocha'
end
group :development do
#gem "nifty-generators", "0.4.3", :git => "git://github.com/JonasNielsen/nifty-generators.git"
gem 'fastercsv'
end
gem "mocha", :group => :test
Do you think the error is because I left out the two gems with "#" ? Those were causing problems at first, and I don't think I need them to test some minor changes in the app (some views that I have to modify)
The issue is being described, and supposedly fixed here: https://github.com/collectiveidea/delayed_job/issuesearch?state=open&q=yaml#issue/194
Try this from the command line: irb -rubygems -r delayed_job and then from your bundled directory bundle-exec irb -rubygems -r delayed_job which will show if there is a difference between your system gems and your bundled setup - you might see an error in one or both attempts to run IRB.
If there is an error using bundle-exec but not with your system gems then it's a bundler issue. If not, are you sure the app is designed to function under Ruby 1.9? It looks like to_yaml isn't available at the point DJ is required, which implies it probably needs a require "yaml" somewhere.

'Could not find gem' error when specifying a forked version of a gem from Github in my gemfile

I am trying to use this forked version of the searchlogic gem. In my gemfile, I have
gem "searchlogic", :git => "http://github.com/railsdog/searchlogic.git"
when I do bundle install, I get this error:
Could not find gem 'searchlogic (>= 0, runtime)' in http://github.com/railsdog/searchlogic.git (at master).
Source does not contain any versions of 'searchlogic (>= 0, runtime)'
What is causing this error? Thanks for reading.
It's because your fork not define searchlogic gem by rd_searchlogic gem. So use in your Gemfile :
gem "rd_searchlogic",
:git => "rd_searchlogic.gemspec",
:require => "searchlogic"
Use:
gem 'rd_searchlogic', :git => 'https://github.com/railsdog/searchlogic.git', :require => 'searchlogic'
The .gemspec of your fork might contain a different name to that of the gem on RubyGems, for example when I forked active_merchant on GitHub their .gemspec file had:
s.name = 'activemerchant'
but the gem is defined as active_merchant on RubyGems so I changed my Gemfile from:
gem "active_merchant", git: "https://github.com/adamwaite/active_merchant.git", require: "active_merchant"
to:
gem "activemerchant", git: "https://github.com/adamwaite/active_merchant.git", require: "active_merchant"
note the lack of _.
All worked perfectly after that. This may be an obscure case, but hope it helps someone!
It doesn't look like that gem has been upgraded for Rails3. From the issues listed in Github, it seems that searchlogic is heavily dependent on ActiveRecord2 and may not be easily upgraded for Rails 3. It may be worth looking into an alternative.
Will searchlogic work with Rails 3?
http://github.com/binarylogic/searchlogic/issues/issue/65

Resources