Re: Problem with RailsDispatcher

Kim Shrier <[email protected]> Thu, 30 Nov 2006 12:56:46 -0700
Newsgroups gmane.comp.apache.mod-ruby
Message-ID <[email protected]>
On Nov 30, 2006, at 10:54 AM, Andre Nathan wrote:

> Hello
>
> I'm having some trouble trying to configure mod_ruby 1.2.6 with
> RailsDispatcher. When I access my application, the browser shows the
> contents of dispatch.rb.
>
> Here's the configuration I'm using:
>
>
> RubySafeLevel 0
> RubyRequire rubygems
> RubyRequire apache/rails-dispatcher
> RubyTransHandler Apache::RailsDispatcher.instance
>
> <VirtualHost x.y.z.w>
>   ServerName myapp.foo.com
>   ServerAlias www.myapp.foo.com
>
>   DocumentRoot /var/www/rails/myapp/public/
>
>   <Directory /var/www/rails/myapp/public/>
>     Options ExecCGI FollowSymLinks IncludesNOEXEC Indexes
>     AllowOverride All
>     Order allow,deny
>     Allow from all
>   </Directory>
>
>   SetHandler ruby-object
>   RubyHandler Apache::RailsDispatcher.instance
>   RubyOption rails_uri_root /
>   RubyOption rails_root /var/www/rails/myapp
>   RubyOption rails_env production
>
>   SetOutputFilter DEFLATE
> </VirtualHost>
>
>
> I did some debugging in rails-dispatcher.rb, and in the #handler  
> method,
> I noticed it's returning DECLINED at the beginning, because the
> r.filename contains the whole path to dispatch.rb, and thus doesn't
> match /\Adispatch\.(cgi|fcgi|rb)\z/. Anyone seen this problem too?
> Removing the "\A" from the regex makes it match, but then I get some
> strange errors (stack level too deep) which don't happen in CGI mode.
>
> Anything obvious I could be missing?
>
> Thanks
> Andre
>
>
>

You might want to try enclosing the ruby directives inside the
VirtualHost in a Location specification.

...
   <Location />
     SetHandler ruby-object
     RubyHandler Apache::RailsDispatcher.instance
     RubyOption rails_uri_root /
     RubyOption rails_root /var/www/rails/myapp
     RubyOption rails_env production
   </Location>


If this doesn't work, it would be useful to see the contents of
the .htaccess file in /var/www/rails/myapp/public.

As an aside, I would change the "AllowOverride All" specification
on the public directory to "AllowOverride None" and move any
configuration directives you need out of the .htaccess file and
into your httpd.conf file.  This will make your accesses faster
since the apache web server does not need to merge the .htaccess
directives into its server configuration and re-evaluate the
request with the updated configuration on every request that
goes to /var/www/rails/myapp/public.

Kim
--
  Kim Shrier - principal, Shrier and Deihl - mailto:[email protected]
Remote Unix Network Admin, Security, Internet Software Development
   Tinker Internet Services - Superior FreeBSD-based Web Hosting
                      http://www.tinker.com/