problem with 'load_plugin' when starting WEBrick server

7 views
Skip to first unread message

fiend

unread,
Aug 1, 2008, 7:21:31 PM8/1/08
to Ruby on Rails: RFPDF
I've been trying to get a sample PDF created for a long time now. I
finally took note of the version of GitHub, so I tried using that
version to see if it made things any easier, but I can't even get the
server started. I'm far from an expert Rails developer, but I feel
like things should be working now given the initiatives I've tried.

I can at least get the server started with the other version of RFPDF,
the one shown at <http://dry.4thebusiness.com/?document=3>, but using
that version I have a lot of strange problems that I just assumed had
something to do with it being an older version, so I tried the version
on GitHub. Namely, the one on GitHub actually has files for tcpdf,
which is what the DRY Scaffold example uses (as with pdf=TCPDF.new)...
its a wonder why the SVN they have there doesn't have tcpdf in it...

First I should mention how I installed the RFPDF plugin... I did this
using the GitGUI for Windows, used the URL for the clone that Ed Moss
provided on his page, and I successfully get a trunk. So I just copy &
paste into MyApp/vendor/plugins.

Upon starting WEBrick, I get the following series of errors:

=> Booting WEBrick...
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/
dependencies.rb:263:in `load_missing_constant': uninitialized constant
ActionView::Template (NameError)
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/
active_support/dependencies.rb:452:in `const_missing'
from C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/rfpdf/environment.rb:
19
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/
active_support/dependencies.rb:495:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/
active_support/dependencies.rb:342:in `new_constants_in'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/
active_support/dependencies.rb:495:in `require'
from C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/rfpdf/init.rb:4:in
`load_plugin'
... 23 levels...
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
from ./script/server:3
from -e:4:in `load'
from -e:4


My environment:
Ruby 1.8.6
Rails 1.2.6
ActiveScaffold 1.1.1
ActiveScaffoldTools from GitHub
testing on local host in Windows Vista using EasyEclipse for LAMP


Thanks guys for all the help!

javinto

unread,
Aug 2, 2008, 3:52:13 AM8/2/08
to Ruby on Rails: RFPDF
Hi!

Rails 2.1 changed the way internally in which Templates are handled.
This is where the 'former' version of the RFPDF Plugin failed.
This had changed now to make it compatible with Rails 2.1.
Unfortunately this means that it will break with older versions of
Rails, like yours.

So, time to upgrade to Rails 2.1 I guess.

Edwin Moss

unread,
Aug 2, 2008, 12:13:12 PM8/2/08
to Ruby on Rails: RFPDF
Note that the github repos has a 1.2.x tag and the trunk/master has a
commit indicating that 2.1 compatibility was added.

fiend

unread,
Aug 3, 2008, 4:36:05 PM8/3/08
to Ruby on Rails: RFPDF
Thanks guys for the help. Unfortunately, I am sort of stuck with rails
1.2.6, due to compatibility issues with other plugins I'm using. But
the way I see it is I should still be able to get this to work...
people did before so surely they can now.

The first step was as Ed Moss said take a look at the older version,
which I did. I installed the original commit version on my app, and
now I can start the server. Then I was only getting missing font
errors.. which was easily fixed. I feel like I'm closer than I've ever
been before to just getting that sample PDF to create.

I moved some things around and now I'm down to this error:

====================================
TypeError in Shorts#print_pdf

Showing app/views/shorts/_print_list.rhtml where line #8 raised:

can't convert nil into String

Extracted source (around line #8):

5: text_options = {:font => "freeserif"}
6: @pdf.draw_text(15, 10, "text", {:font_size => 12, :font =>
"freeserif"})
7: %>
8: <%=@pdf.Output()%>
====================================

Below I have provided the session dump, if it helps. My whole thing is
I just don't understand why I can't get things to work like the DRY
Scaffold example. It seems to me I'm having to go about it a whole
different way. They used a controller called report and an associated
helper and view. When I take that approach, the plugin keeps nagging
at me saying I don't have template of type rhtml or xml called
_print_list. First off, why must it be _print_list? All the examples I
see online don't have a _print_list file...

So anyways I figured I'd just follow through with what it said, and I
made the _print_list.rhtml file with the very simple example rhtml
code provided in the README for the plugin, and I'm down to the error
I mentioned above.

Do you guys think the errors I'm getting might be linked to
incompatible version of ActiveScaffoldTools? I'm using ActiveScaffold
and hence ASTools to get the "Print PDF" button above my scaffold
view, much like the DRY Scaffold example. I got my ASTools off of
GitHub.

Here's the session dump:

========================================================
C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/rfpdf/lib/tcpdf.rb:2295:in
`open'
C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/rfpdf/lib/tcpdf.rb:2295:in
`putfonts'
C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/rfpdf/lib/tcpdf.rb:2290:in
`each'
C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/rfpdf/lib/tcpdf.rb:2290:in
`putfonts'
C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/rfpdf/lib/tcpdf.rb:2514:in
`putresources'
C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/rfpdf/lib/tcpdf.rb:2599:in
`enddoc'
C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/rfpdf/lib/tcpdf.rb:734:in
`Close'
C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/rfpdf/lib/tcpdf.rb:2083:in
`Output'
C:/Users/Fiend/Eclipse/MyApp/app/views/shorts/_print_list.rhtml:8:in
`_run_rhtml_47app47views47shorts47_print_list46rhtml'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_view/
base.rb:325:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_view/
base.rb:325:in `compile_and_render_template'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_view/
base.rb:301:in `render_template'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_view/
base.rb:260:in `render_file'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_view/
base.rb:275:in `render_without_active_scaffold'
C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/active_scaffold/lib/
extensions/action_view_rendering.rb:60:in `render'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_view/
partials.rb:59:in `render_partial_without_active_scaffold'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
benchmarking.rb:26:in `benchmark'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/1.8/benchmark.rb:307:in `realtime'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
benchmarking.rb:26:in `benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_view/
partials.rb:58:in `render_partial_without_active_scaffold'
C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/active_scaffold/lib/
extensions/action_view_rendering.rb:70:in `render_partial'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
base.rb:856:in `render_partial'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
base.rb:768:in `render_with_no_layout'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
layout.rb:256:in `render_without_benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
benchmarking.rb:50:in `render_without_active_scaffold'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
benchmarking.rb:50:in `render_without_active_scaffold'
C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/active_scaffold/lib/
extensions/action_controller_rendering.rb:13:in `render'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
base.rb:792:in `render_to_string'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/
deprecation.rb:44:in `silence'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
base.rb:792:in `render_to_string'
C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/activescaffoldtools/lib/
actions/print_pdf.rb:14:in `print_pdf'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
mime_responds.rb:135:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
mime_responds.rb:135:in `custom'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
mime_responds.rb:167:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
mime_responds.rb:167:in `respond'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
mime_responds.rb:161:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
mime_responds.rb:161:in `respond'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
mime_responds.rb:105:in `respond_to'
C:/Users/Fiend/Eclipse/MyApp/vendor/plugins/activescaffoldtools/lib/
actions/print_pdf.rb:12:in `print_pdf'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
base.rb:1101:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
base.rb:1101:in `perform_action_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
filters.rb:696:in `call_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
filters.rb:688:in `perform_action_without_benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
benchmarking.rb:66:in `perform_action_without_rescue'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
benchmarking.rb:66:in `perform_action_without_rescue'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
rescue.rb:83:in `perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
base.rb:435:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
base.rb:435:in `process_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
filters.rb:684:in `process_without_session_management_support'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
session_management.rb:114:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/
base.rb:334:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:41:in
`dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/webrick_server.rb:
113:in `handle_dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/webrick_server.rb:79:in
`service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/webrick_server.rb:63:in
`dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/commands/servers/
webrick.rb:59
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/
dependencies.rb:495:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/
dependencies.rb:342:in `new_constants_in'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/
dependencies.rb:495:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/commands/server.rb:39
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/
dependencies.rb:495:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/
dependencies.rb:342:in `new_constants_in'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/
dependencies.rb:495:in `require'
script/server:3
-e:4:in `load'
-e:4
==========================================================

Thanks so much for all the help. I feel certain this will be of great
assistance to other struggling developers out there trying to simulate
the DRY Scaffold example.

javinto

unread,
Aug 3, 2008, 5:10:33 PM8/3/08
to Ruby on Rails: RFPDF

Hi,

I'm not quite sure how you implemented things, but here's the way I
did it:

Within you ShortsController#print_pdf:
@short = Short.find(:all)
render :action=>'short_in_pdf', :layout=>false
end

Then in your views: \views\shorts\short_in_pdf.rfpdf
This is your pdf file: <% pdf = PDF.new() %>
...etc
<% pdf.Output() %>

Hopes this helps
Reply all
Reply to author
Forward
0 new messages