# Routes

**URL:** <https://www.ruby-forum.com/t/routes/143525>\
**Category:** Rails\
**Created:** [July 19, 2008, 11:52pm UTC](https://www.ruby-forum.com/t/routes/143525 "2008-07-19T23:52:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![papacostas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@papacostas](https://www.ruby-forum.com/u/papacostas)\
**Post date:** [July 19, 2008, 11:52pm UTC](https://www.ruby-forum.com/t/routes/143525/1 "2008-07-19T23:52:16Z")

</div>

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/](http://localhost:3000/share/) - outputs no params  
[http://localhost:3000/share/index](http://localhost:3000/share/index) - ouputs no params  
[http://localhost:3000/share/index/[anything]](http://localhost:3000/share/index/%5Banything%5D) - outputs no params  
[http://localhost:3000/share/[anything]](http://localhost:3000/share/%5Banything%5D) - 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.

---

<div class="post-metadata">

**Author:** ![papacostas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@papacostas](https://www.ruby-forum.com/u/papacostas)\
**Post date:** [July 20, 2008, 1:37am UTC](https://www.ruby-forum.com/t/routes/143525/2 "2008-07-20T01:37:51Z")

</div>

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.

–  
Phlip
