Ruby Forum Rails France > if ".com" becomes part of the URL, Routing error is flashed

Posted by Sandeep Gudibanda (sgudibanda)
on 25.07.2008 14:57
Hi,

I am trying to list companies in a catalog. I have set following route
for that

map.connect 'company/:company'
            :controller => 'community',
      :action => 'search'

Now I have ".com" as a part of the company name(Amazon.com), then my app
flags out an error stating:
no route found to match "/company-profile/amazon.com" with
{:method=>:get})

How can i avoid this?

Regards,
SG
Posted by Fabien Jakimowicz (Guest)
on 25.07.2008 15:06
(Received via mailing list)
On Fri, Jul 25, 2008 at 14:57, Sandeep Gudibanda
<list-incoming@andreas-s.net> wrote:
> Now I have ".com" as a part of the company name(Amazon.com), then my app
> flags out an error stating:
> no route found to match "/company-profile/amazon.com" with
> {:method=>:get})
>
> How can i avoid this?
>

Just specify a catchall condition on the parameter :

map.connect 'company/:company', :controller => 'community', :action =>
'search', :company => /.*/

PS: this mailing list is almost french oriented ;)

--
http://fabien.jakimowicz.com
Posted by Sandeep Gudibanda (sgudibanda)
on 25.07.2008 16:02
As long as some like you is there, I don't mind at all :):)
Thanks a lot. This works.


Fabien Jakimowicz wrote:
> On Fri, Jul 25, 2008 at 14:57, Sandeep Gudibanda
> <list-incoming@andreas-s.net> wrote:
>> Now I have ".com" as a part of the company name(Amazon.com), then my app
>> flags out an error stating:
>> no route found to match "/company-profile/amazon.com" with
>> {:method=>:get})
>>
>> How can i avoid this?
>>
> 
> Just specify a catchall condition on the parameter :
> 
> map.connect 'company/:company', :controller => 'community', :action =>
> 'search', :company => /.*/
> 
> PS: this mailing list is almost french oriented ;)
> 
> --
> http://fabien.jakimowicz.com