Welcome to Working With Rails


Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Apache ActionController:RoutingError
9 Posts
Apache ActionController:RoutingError

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'

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

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.

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

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.

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

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.

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. :)

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.

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. 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

9 Posts
Login to add your message