views:

29

answers:

3

Ok so i have an application that i use this jquery

$("#band_events").load("/load_events/"+ escape($('#request_artist').val()), successCallback );

It works great but if #request_artist is R.E.M. or somehthing with decimals or something weird rails has problems like

ActionController::RoutingError (No route matches "/load_events/R.E.M." with {:method=>:get}):

here is my routes line

map.load_events '/load_events/:band', :controller => 'pages', :action => 'load_events'

Any suggestions

+1  A: 

To escape a URL you should use encodeURIComponent instead of escape.

Justin Ethier
this still failing /load_events/R.E.M.
Matt
No route matches "/load_events/R.E.M." with {:method=>:get}
Matt
+1  A: 

I would try

map.connect ... , :constraints => { :band => /.*/ }

(Or any other pattern of your taste.) About constraints

It doesn't seem to be working in all versions of rails, though. I'm pretty sure I used this trick before, but can't get it to work now. So, good luck with it.

Nikita Rybak
+1  A: 

Check this out. This worked for me. Pretty neat solution, I would say - http://stackoverflow.com/questions/2787527/ending-a-rails-2-url-with-an-ip-address-causes-routing-error

Rohit