Tick-Tock
Tick-Tock

Reputation: 83

no such file to load -- RMagick.rb Rails, Ubuntu

I have ruby and my gems installed in my home directory using rvm. 'require RMagick' works from the console and irb, but not from within my Rails app. I have the gem listed in my Gemfile.

require 'RMagick'

class PetsController < ApplicationController
  def image
    image = Image.new(image_path("base/Base.png"))
    #image = Pet.composite(0, '4a4a4a')
    @response.headers["Content-type"] = image.mime_type
    render :text => image.to_blob
  end

end 

If I remove the require from my controller, I get

uninitialized constant PetsController::Image

I also have tried require 'RMagick' in boot.rb, and by referring to the Image object using Magick::Image (which gives me uninitialized constant PetsController::Magick.

What am I doing wrong?

Upvotes: 0

Views: 727

Answers (2)

Tick-Tock
Tick-Tock

Reputation: 83

Solved it! Restarting the server fixed it. I guess I hadn't restarted the server when I added rmagick to my gemfile.

Upvotes: 1

Tudor Constantin
Tudor Constantin

Reputation: 26861

Is it possible that you are running the rails app with another user than the one that has the RMagick gem installed?

Upvotes: 0

Related Questions