Routes

Hi there,
I'm having an issue with routes I frankly dont get.
I have a controller named map which takes in a hash string and converts
that to an actual url, works great

so localhost:3000/f3gg or whatever works fine

now, I have a controller which I want to use to add some records (needs
to go through AJAX)

I want two strings, from and to but nevermind that for now since I'm too
stupid to even get one string working

my routes.rb look like this

  map.connect ':controller/:action/:id.:format'
  map.connect ':controller/:action/:id'
  map.connect ':map', :controller=>'map', :action=> 'index'
  map.connect ':from', :controller=>'share', :action=> 'index'
  map.connect '', :controller => "map"

the map one in the middle works fine, the controller looks like this:
(cut out all the irrelevant stuff)

class MapController < ApplicationController
  def index
    @map = getmap
  end
  def getmap
    if params['map'] then
     @map = params['map']
     end
  end
end

now, for the "share" one I cant for the life of me get any values out of

class ShareController < ApplicationController
  def index
     if params['from'] then
      @map = params['from']
    else
      @map = 'no params'
     end
  end
end

i've tried

http://localhost:3000/share/ - outputs no params
http://localhost:3000/share/index - ouputs no params
http://localhost:3000/share/index/[anything] - outputs no params
http://localhost:3000/share/[anything] - outputs "Exception caught -
Action not found"
but I dont want it to think its an action i want it to take the url
value, like it does in the maps one

any help with this would be greatly appreciated, and yes im not a very
experienced ROR developer.

Johan Mickelin wrote:

I want two strings, from and to but nevermind that for now since I'm too
stupid to even get one string working

How is assert_routing working out for you?

my routes.rb look like this

  map.connect ':controller/:action/:id.:format'
  map.connect ':controller/:action/:id'
  map.connect ':map', :controller=>'map', :action=> 'index'
  map.connect ':from', :controller=>'share', :action=> 'index'
  map.connect '', :controller => "map"

The router drops thru each connect, in order, looking for an adequate match. Because you have a controller called Share, the /share routes matches ':controller...' prematurely.

Always put the generic routes _below_ the specific routes.

After all this works, name your routes. I don't think Rails has a reason not to name all routes:

   map.from_share ':from', :controller=>'share', :action=> 'index'

Now you can use from_share_url in your source, instead of reassembling the url with url_for.