Browse the Ruby on Rails Community.

You are here: Forums Ask a Rails expert Apache ActionController:Routin...

Replytotopic

Apache ActionController:RoutingError

Posted in Forums : Ask a Rails expert

 
Profile

Authority 12
Posting Rating 0
Sign in to rate this post

I’ve been working on an app on my Mac and it is working fine with both Mongrel and Apache. I copied it to our Linux server, which I have very little control over, and it works with Mongrel but fails on Apache. I created an empty app, ‘testapp’, and when I click on “About your application’s environment”, this is what I get …
[code]
Processing ApplicationController#index (for #.#.#.# at 2008-05-13 13:55:59) [GET] Session ID: BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%0ASGFzaHsABjoKQHVzZWR7AA%3D%3D—2514c0409d801b56c654f688e51ba4c50eeb328e Parameters: {}

ActionController::RoutingError (No route matches ”/testapp/public/rails/info/properties” with {:method=>:get}): /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1441:in `recognize_path’ /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1424:in `recognize’ /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in `handle_request’ /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch’ /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi’ /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch’ /usr/htdocs/testapp/public/dispatch.cgi:10

Rendering /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/templates/rescues/layout.erb (not_found)
[/code]
I’ve seen others mention the same or similar problem, but no solutions. I’m assuming that this is an apache configuration issue. I’d greatly appreciate any help as I’m dead in the water. (BTW, I have posted this on another forum, but it got no response.)

TIA
Jake

 
Me

Authority 37
Posting Rating 100
Sign in to rate this post

As far as I know, this URL only works for local requests and/or in development mode.

FYI, the controller to do this sits in the unpacked Rails gem directory in railties/builtin/rails_info/. If you have freezed Rails (and you should do that, especially if you’re in an environment that you can’t configure yourself – read the “Vendor Everything” approach here), you’ll find it in vendor/rails/railties/builtin/rails_info/.

But: Why would you need the default index.html anyway?

 
Profile

Authority 12
Posting Rating 0
Sign in to rate this post

I’m sorry for the confusion. The error happens for all of my requests to my app. I created the test app just as a test to see if I mucked something up, but it responds the same way. I am still in development mode. Normally, when not on localhost, it would respond by saying that it only works on localhost, but not by erroring. I’m guessing that there is something missing from the apache installation.

 
Profile

Authority 12
Posting Rating 96
Sign in to rate this post

Can you post your Apache config? Looks like DocumentRoot might be set to RAILS_ROOT, it should be RAILS_ROOT/public.

 
Profile

Authority 12
Posting Rating 0
Sign in to rate this post

The httpd.conf file is huge, so it would be awkward to post the whole thing. This app, and those that may follow in the future, are just in subdirectories of the DocumentRoot and accessed via http://myserver.com/jake/testapp/public (for now). This is ugly and temporary, but works just fine on my iMac. RAILS_ROOT is initially unset so is set in boot.rb.

 
Profile

Authority 12
Posting Rating 96
Sign in to rate this post

I think it will work out a lot easier for you if you arrange it so that your server root is the same as your rails root. i.e. requesting http://example.com/index.html would serve up RAILS_ROOT/public/index.html

Personally I always use a vhost, using a template similar to this: http://brainspl.at/articles/2006/06/12/apache2-2-vhost-template-for-mongrel-clusters

 
Profile

Authority 12
Posting Rating 0
Sign in to rate this post

The apache server is already serving a lot of other pages and several subdomains so I think changing the server root is out of the question and I doubt that the administrators would be willing to meddle with virtual hosts. In the end, it would make for a cleaner app, but I just don’t see why either of them are necessary. All of the rails apps that I toyed with on my Macs work in there own subdirectories. They even worked when I used them on GoDaddy. There has to be something super simple that rails is expecting that isn’t there.

 
Profile

Authority 12
Posting Rating 96
Sign in to rate this post

Hi Jake

It just looks wrong to have “public” there in your url. What do you get if you request http://myserver.com/jake/testapp/config/database.yml ?

When you’ve made it work in the past, what have you done to configure the rails url helper methods so that they return /jake/testapp/public/controller/action/id URLs rather than /controller/action/id ?

I’m not saying that what you want can’t be done, it’s just that you’re really swimming against the tide of how it’s been designed to work. Rails URLs are designed to be simple, commonly /controller/action/id.

If there is something you can tweak in environment.rb to change the behaviour of the url helper methods, it might be useful to know for the future. :)

 
Profile

Authority 12
Posting Rating 0
Sign in to rate this post

It actually shows my database.yml! I’ve got full browsing privileges to all the subdirs! This just ain’t supposed to be! Clearly I need to add a .htaccess file here with some restrictions. Any idea of what exactly I need to put in it?

I created one with …
RewriteEngine On
RewriteRule !/public/dispatch.cgi [F]
... in it and it stops my browsing, but the routing issue still exists.

Until recently, when I upgraded to 2.0, I haven’t meddled with the routes. My empty test app just has the default routes.

 
Profile

Authority 12
Posting Rating 96
Sign in to rate this post

Yes, you could lock it down with .htaccess files, but that still leaves you with the problem of all the rails url helpers returning the wrong URL.

e.g. <%= link_to “Add product”, new_product_url %> will produce a link with href /products/new, not /jake/testapp/public/products/new.

Actually I’ve just done a bit of googling and found this: http://rubyforge.org/pipermail/mongrel-users/2006-July/000607.html so maybe it will work OK after all. Those long URLs are still pretty icky though.

To block an entire directory using a .htaccess file, I think it’s probably as simple as:

Order Allow,Deny

according to the wording at the end of the reference docs: http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order

Replytotopic

Other Recent Topics

Ask a Rails expert : Sanitizing html

Ask a Rails expert : First post, requesting sage perspective

Ask a Rails expert : How to use mephisto

Ask a Rails expert : How to use mephisto

Ask a Rails expert : will_paginate customization problem

Ask a Rails expert : BackgroundRB still wants 'development' environment...?

Ask a Rails expert : activescaffold, sql exception

Ask a Rails expert : Passing non-english chars in query string

Ask a Rails expert : Rails and 2D barcodes

Ask a Rails expert : apache giving proxy error

Formatting Help
  • *bold*       _italics_      
    bq. (quotes)
  • "DSC":http://www.dsc.net
  • * or # (lists)
or cancel