This project is archived and is in readonly mode.

#5224 needs-more-info

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.


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


class RmagicController < ApplicationController

  require 'RMagick'
  include Magick

  def index
    img =, 'images/test.jpg')).first
    send_data(img.to_blob, { :type => 'image/jpeg', :disposition => "inline" })

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=""></a>