http://localhost:3000/stations/103.3I created a route in routes.rb defined to match a radio station by frequency:
map.connect 'stations/:frequency', :controller => 'stations', :action => :showWhich I thought would do the trick, but instead I get the dreaded:
But it works without the dot (for AM stations)No route matches "/stations/103.3" with {:method=>:get}
http://localhost:3000/stations/1120What gives?
The problem, I found in Rails bug reports, is that this is desired behavior. The dot is, by default considered separator, just like a slash. One way to fix this is to specify the pattern for frequency as anything which is not a slash:
map.connect 'stations/:frequency', :controller => 'stations', :action => :show, :frequency => /[^\/]+/Which does the trick
No comments:
Post a Comment