This project is archived and is in readonly mode.

#5224 needs-more-info
Vincent

Rmagick doesn't work

Reported by Vincent | July 28th, 2010 @ 04:16 AM

I've encountered a really strange problem with the latest Rails master. Anything that involves RMagick gem will run OK on the first request and generate 'uninitialized constant' error on all subsequent requests, until you restart WEBrick. Try running the attached app and just refresh the page. I didn't have this problem 2 days ago. I'm using Ruby 1.9.2dev on Ubuntu Linux 10.04.

Error:

ActionController::RoutingError (uninitialized constant RmagicController::Magick):
  app/controllers/rmagic_controller.rb:4:in `<class:RmagicController>'
  app/controllers/rmagic_controller.rb:1:in `<top (required)>'

rmagic_controller.rb:

class RmagicController < ApplicationController

  require 'RMagick'
  include Magick

  def index
    img = Magick::Image.read(File.join(Rails.public_path, 'images/test.jpg')).first
    send_data(img.to_blob, { :type => 'image/jpeg', :disposition => "inline" })
  end
end

Comments and changes to this ticket

  • Andrew White

    Andrew White February 9th, 2011 @ 07:07 AM

    • State changed from “new” to “needs-more-info”
    • Importance changed from “” to “Low”

    Vincent, this sounds very much like an issue with class reloading in development mode - the classic sign is the working on first request and not subsequent requests. It'll probably work fine in production mode or if you set config.cache_classes = true in config/environments/development.rb.

    If you remove the require and include from the controller it should also work as the Gemfile should be loading RMagick anyway. I'm guessing that your running on a case sensitive filesystem so your gem line in the Gemfile should be:

    gem 'rmagick', :require => 'RMagick'
    

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages