mod_ruby on apache 1.3.33 routes.rb issues
Ernie Oporto <[email protected]> Sun, 30 Oct 2005 13:07:59 -0500
| Newsgroups | gmane.comp.apache.mod-ruby |
|---|---|
| Message-ID | <[email protected]> |
Up until now I've been working with ruby and rails using the build-in server
that displays at port 3000. I'd like to get it working on apache, but it
seems all I get is the "Welcome on board" screen, which I guess shows that
something is working.
Installed ruby, rubygems, rails, mysql gem 2.7
cd /usr/web/content
rails Todo
edit stuff
went through the nice Todo tutorial at
http://manuals.rubyonrails.com/read/book/7 and have the demo working at
http://www.shokk.com:3000/todo/list when I run "ruby script/server" in
/usr/web/content
I compiled and installed the mod_ruby module for Apache 1.3.33 which loads
fine and displays the "Welcome on board" message at
http://www.shokk.com/Todo/ (hopefully this means its working?)
However, if I get rid of /usr/web/content/Todo/public/index.html, I only get
the "Application error: Rails application failed to start properly" screen
when I access that page or even http://www.shokk.com/Todo/todo/
Apache is set up as follows...
[...]
LoadModule ruby_module libexec/mod_ruby.so
LoadModule rewrite_module libexec/mod_rewrite.so
ClearModuleList
[...]
AddModule mod_ruby.c
AddModule mod_rewrite.c
<IfModule mod_ruby.c>
# for Apache::RubyRun
RubyRequire apache/ruby-run
# exec files under /ruby as ruby scripts.
<Location /usr/web/content/Todo>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
Options +ExecCGI
</Location>
# exec *.rbx as ruby scripts.
<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
</Files>
RubyRequire apache/eruby-run
RubyRequire auto-reload
</IfModule>
<Directory /usr/web/content/Todo>
Options ExecCGI FollowSymLinks
AddHandler cgi-script .cgi
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<IfModule mod_alias.c>
Alias /Todo/ "/usr/web/content/Todo/public/"
</IfModule>
The .htaccess in the Todo/public directory has this added...
RewriteEngine On
RewriteBase /Todo
I also modified public/dispatch.cgi to use the absolut path as recommended
for mod_ruby...
require "/usr/lib/ruby/gems/1.8/gems/rails-0.14.2/lib/dispatcher"
Apache error.log has the following...
/usr/lib/ruby/1.8/pstore.rb:28:in `initialize': file
/tmp/ruby_sess.7892770eff7d0d3e not readable (PStore::Error)
from /usr/lib/ruby/1.8/cgi/session/pstore.rb:70:in `initialize'
from /usr/lib/ruby/1.8/cgi/session.rb:273:in `initialize'
from /usr/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/cgi_process.rb:97:in
`session'
from /usr/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/base.rb:815:in
`assign_shortcuts'
from /usr/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/base.rb:359:in
`process_without_session_management_support'
from /usr/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/session_management.rb:116:in
`process'
from /usr/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/rescue.rb:20:in
`process_with_exception'
from /usr/lib/ruby/gems/1.8/gems/rails-0.14.2/lib/dispatcher.rb:38:in
`dispatch'
from /usr/web/content/Todo/public/dispatch.cgi:11
[Sun Oct 30 12:27:59 2005] [error] [client 192.168.5.104<http://192.168.5.104>]
Premature end of script headers: /usr/web/content/Todo/public/dispatch.cgi
well, after spotting that, I blow away all the /tmp/ruby_sess.* files and
get
Routing Error: Recognition failed for "/"
Adding this as the first mapping to config/routes.rb
map.connect "", :controller => "todo" , :action => "list"
It seems to fix things right away! I am able to see the first "list" screen
of the demo, but disappointingly when I try to click "Add item" I am back to
the same type of error...
Routing Error: Recognition failed for "/add_item"
and development.log shows...
Processing Base#index (for 192.168.5.104 <http://192.168.5.104> at
2005-10-30 12:56:27) [POST]
Parameters: {"new_item"=>{"description"=>"test"}}
ActionController::RoutingError (Recognition failed for "/add_item"):
/usr/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/routing.rb:469:in
`recognition_failed'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/routing.rb:459:in
`recognize!'
/usr/lib/ruby/gems/1.8/gems/rails-0.14.2/lib/dispatcher.rb:36:in `dispatch'
/public/dispatch.cgi:11
Rendering /usr/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/templates/rescues/layout.rhtml
(404 Page Not Found)
And of course, adding that screws up anything that used to work at
http://www.shokk.com:3000/todo/list where submitting the form will actually
add stuff to the list, but it takes me back to the "Welcome on board!" page.
Can anyone spot any blatantly boneheaded mistakes or anything missing? I
guess the routes config is the key here. Right now the URL is open for
anyone to play with and see the error since it doesn't do much. Any help and
comments are appreciated.