Discussion:
Requiring Gems
Rick Shafer
2007-08-27 07:18:53 UTC
Permalink
OK... I can see that this topic has appeared several times, at least
by doing a google, but I can't seem to be able to decode/apply any of
the solutions (which often seem to be "oops, now its working"... I
hate that sort of solution when my situation isn't working).

Here is the situation...
I am running Locomotive 2.0.8 with the RMagick Rails Mar 2007
bundle. I am running on a dual G5. OS 10.4.10.

I wanted to use the PDF::Writer package. So, I went into the
Locomotive launched terminal window for my project and ran:
gems update pdf-writer
It prompted me for several dependencies (I said yes), it built two
kinds of documentation (rdoc was one of them), and then I got a
prompt, and assumed that it had installed... somewhere.... (I seemed
to find it but it was WAY deep and in multiple places (though some of
it is the rdoc.... and a CVS entry?)). The docs were in "PDF/Writer"
as opposed to "pdf/writer".

Locomotive2/Bundles/rmagickRailsMar2007_ppc.locobundle/framework/lib/
ruby/gems/1.8/gems/pdf-writer-1.1.3/lib/pdf/writer/

The documentation for PDF::Writer included a "hello world" example,
which I wanted to test.
require "pdf/writer"
pdf = PDF::Writer.new
pdf.select_font "Times-Roman"
pdf.text "Hello, Ruby.", :font_size => 24, :justification
=> :center
pdf.save_as("hello.pdf")

I saved this as a simple file testwriter.rb at the top of my rails
app hierarchy, and then at the terminal prompt say

ruby testwriter.rb

whereupon, I get the message
testwriter.rb:5:in `require': no such file to load -- pdf/writer
(LoadError)
from testwriter.rb:5

So, what am I doing wrong? Is it in gems? ruby? Locomotive? bad
karma?

Thanks for your attention.
Ryan Raaum
2007-08-27 10:12:26 UTC
Permalink
Post by Rick Shafer
OK... I can see that this topic has appeared several times, at least
by doing a google, but I can't seem to be able to decode/apply any of
the solutions (which often seem to be "oops, now its working"... I
hate that sort of solution when my situation isn't working).
Here is the situation...
I am running Locomotive 2.0.8 with the RMagick Rails Mar 2007
bundle. I am running on a dual G5. OS 10.4.10.
I wanted to use the PDF::Writer package. So, I went into the
gems update pdf-writer
It prompted me for several dependencies (I said yes), it built two
kinds of documentation (rdoc was one of them), and then I got a
prompt, and assumed that it had installed... somewhere.... (I seemed
to find it but it was WAY deep and in multiple places (though some of
it is the rdoc.... and a CVS entry?)). The docs were in "PDF/Writer"
as opposed to "pdf/writer".
Locomotive2/Bundles/rmagickRailsMar2007_ppc.locobundle/framework/lib/
ruby/gems/1.8/gems/pdf-writer-1.1.3/lib/pdf/writer/
The documentation for PDF::Writer included a "hello world" example,
which I wanted to test.
require "pdf/writer"
pdf = PDF::Writer.new
pdf.select_font "Times-Roman"
pdf.text "Hello, Ruby.", :font_size => 24, :justification
=> :center
pdf.save_as("hello.pdf")
I saved this as a simple file testwriter.rb at the top of my rails
app hierarchy, and then at the terminal prompt say
ruby testwriter.rb
whereupon, I get the message
testwriter.rb:5:in `require': no such file to load -- pdf/writer
(LoadError)
from testwriter.rb:5
So, what am I doing wrong? Is it in gems? ruby? Locomotive? bad
karma?
add

require 'rubygems'

to the beginning of that example.

-r
Post by Rick Shafer
Thanks for your attention.
_______________________________________________
Locomotive-users mailing list
http://lists.raaum.org/mailman/listinfo/locomotive-users
Rick Shafer
2007-08-27 23:25:09 UTC
Permalink
It worked thanks. Am I right in presuming that within the rails app
source code that the require rubygems is effectively already done
automatically? Do I have require rubygems in every .rb file that
uses gem installed code?

Loading...