Forum: Ruby on Rails RMagick not working

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Emmanuel M. (Guest)
on 2007-03-11 01:23
Hello,

On Windows XP, I got a ruby program using RMagick and working perfectly.
I put this at the begining of my code:

    require 'rubygems'
    require 'RMagick'
    include 'Magick'

Now, when I use the exact same code within Rails, I can't have RMagick
working... It seems it's not initalizing. The include 'Magick' returns
"undefined method `include'" Without the include, I got a "dynamic
constant assignment" when I use an Image or ImageList.

I tried also to remove require'rubygems' which I think should not be
necessary in Rails.

I know there's been tons of post regarding RMagick installation before,
but what puzzles me is it seems to be correctly installed... For
instance, it does appear when doing a gem list...

Any idea?
R. Elliott M. (Guest)
on 2007-03-11 08:44
In my app, I simply have require 'RMagick'

I create new objects like so: Magick::Image.new

I think preceding Image.new is necessary because the class that I am
calling from is named "Image" anyway?  I'm not sure.  Anyway, that works
for me.
Russell N. (Guest)
on 2007-03-11 13:57
(Received via mailing list)
I'm not sure why it'd be giving you the "undefined method 'include'" but
the
proper include is:

include Magick

without the quotes. It's not including a file but in fact telling Rails
to
mixin the methods of the module Magick [in the RMagick library]. I'd
recommend mixing these methods in only in whatever specific class you
plan
on implementing RMagick in.

Also, I tried out the quotes around Magick in the include and got a
different error than the one you're talking about. I got "wrong argument
type String (expected Module) (TypeError)", which makes sense because of
the
reason I said above.

Hope all that helped.

RSL
Emmanuel M. (Guest)
on 2007-03-11 19:52
Oops, actually, I put

require 'RMagick'
include Magick

(without the quotes) in my code, already...
This topic is locked and can not be replied to.