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.
4de6270377c3674a887e1d3ba5cad2cd?d=identicon&s=25 Emmanuel Marotte (marotte)
on 2007-03-11 00: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?
A0f6b57661bc57b6520010a2a333faba?d=identicon&s=25 R. Elliott Mason (eleo)
on 2007-03-11 07: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.
70225136eacd3d870f64e03bff678655?d=identicon&s=25 Russell Norris (Guest)
on 2007-03-11 12: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
4de6270377c3674a887e1d3ba5cad2cd?d=identicon&s=25 Emmanuel Marotte (marotte)
on 2007-03-11 18: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.