understanding routes.rb


I am very new to ruby and rails...but I am trying to get the
LoginGenerator up and running as quick test, but I have run into the
following problem:

Routing Error

no route found to match "/p/arash2/myapp/" with {:method=>:get}

so i figured that i need to change the routes.rb file, and I changed
it to this:

map.connect 'p/myapp/users', :controller => 'users',

and I end up with this error

Unknown action

No action responded to index

I am pretty sure I am missing something big here, and it would be
obvious if I knew rails a bit more, but I am trying to run a
feasibility test, so im more concerned with getting things working
first, and understanding them second.


I’m not sure I understand why your routes look the way they do. Are you running Rails from some kind of subdirectory setup? There’s some added difficulties with doing that. If it’s at all possible, you should run your Rails app from the root level of a domain. It can be in any physical directory on the server but it really [AFAIK] helps to be in the root of the domain.

Also, if you could paste more [or all!] of your routes.rb in your next reply it would help more as well. :slight_smile:


Hi Russell,

thanks for your reply. The reason I am not running from the root of my
domain is because there is already a cgi application (running through
Apache). I really don't want to screw things up there, so I figured I
would just create my application from a sub directory, and run it from
there. Also, I couldn't get Apache to work with rails (albeit I didn't
try very hard, so I just run WEBrick, using port 3000, which is fine
for my feasibility tests).

So anyways, I start WEBrick, and in my browser, I go to:
http://my.domain.com:3000/p/myapp/users (as the LoginGenerator example
directed), but I was getting the following Routing Error:

Routing Error

no route found to match "/p/myapp/" with {:method=>:get}

So I figured the problem was with my routes.rb, but I really don't
understand whats goin on in this file. Also, as you requested, here is
my entire routes.rb (I only added one line, and I have pointed it out)

ActionController::Routing::Routes.draw do |map|
  # The priority is based upon order of creation: first created ->
highest priority.

  # Sample of regular route:
  # map.connect 'products/:id', :controller => 'catalog', :action =>
  # Keep in mind you can assign values other than :controller
and :action

  # Sample of named route:
  # map.purchase 'products/:id/purchase', :controller =>
'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # You can have the root of your site routed by hooking up ''
  # -- just remember to delete public/index.html.
   map.connect 'p/myapp/users', :controller => 'users', :action =>
'start' <-----I added this line

  # Allow downloading Web Service WSDL as a file with an extension
  # instead of a file named 'wsdl'

  #map.connect ':controller/service.wsdl', :action =>
'wsdl' <------I commented this line out (was originally

  # Install the default route as the lowest priority.
':controller/:action/:id.:format' <------
I commented this line out (was originally uncommented)
<------I commented this line out (was originally uncommented)

Thanks again for your help!