Require rmagick

Hello,
I’m trying to use rmagick in a helper script (for auto-generating image
sizes) and I’m not sure where I should be calling ‘require’.

currently I have:
require ‘RMagick’ at the top of my controller:

class FilmsController < ApplicationController
  require 'RMagick'

but that’s giving me an error:

uninitialized constant ImageList

…whenever I try and do anything. From what I’ve read it seems that
this probably a failure to require.

Looking for RMagick in my system I find:

/usr/lib/ruby/gems/1.8/gems/rmagick-1.9.3/lib/RMagick.rb
/usr/local/lib/site_ruby/1.8/RMagick.rb

but do I need to specify where rails should be looking for these files?

dorian


I do things for love or money

+44 (0)7941 219 501

aim:oulalipo | yahoo:tachekent

Pull up IRB and try your require ‘RMagick’ there, see if it is installed
correctly and if ruby knows where to find it. Don’t worry if you get
“false” returned, as long as it doesn’t spit up a bunch of errors.

C:\Code\Work\db\migrate|â?º irb
irb(main):001:0> require ‘RMagick’
=> false
irb(main):002:0> require ‘rgick’
LoadError: No such file to load – rgick
from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
require__' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:inrequire’
from (irb):2
irb(main):003:0>

As for where to call it, so that it is included in your app I’m not
sure. I
do believe >= 1.0 you want to use config/boot.rb. Before 1.0 I used
config/environment. However I’m not sure if that is the way to go.

-B

On Jan 23, 2006, at 6:51 AM, Dorian M. wrote:

but that’s giving me an error:

uninitialized constant ImageList

…whenever I try and do anything. From what I’ve read it seems
that this probably a failure to require.

Looking for RMagick in my system I find:

/usr/lib/ruby/gems/1.8/gems/rmagick-1.9.3/lib/RMagick.rb
/usr/local/lib/site_ruby/1.8/RMagick.rb

RMagick is a shared library, not a ruby script:

$ locate RMagick
/usr/local/lib/ruby/site_ruby/1.8/RMagick.rb
/usr/local/lib/ruby/site_ruby/1.8/i386-freebsd5/RMagick.so

You don’t have RMagick installed correctly.


Eric H. - [email protected] - http://segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com