Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Rmagick doesn't work

#5224

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

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

State: needs-more-info
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Andrew White
    Andrew White
    • 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'
    

    February 9th, 2011 @ 07:07 AM