[Rails 3] "No Route Matches" error when certain params have URL-encoded values

I’ve run into a fairly strange issue recently when testing my Rails
application. I have a route set up as follows in routes.rb:

controller :employees do
match ‘:company/:department/:lastname’ => :show, :via => :get
end

So, doing a request as follows:
get ‘/exampleinc/it/foo’

Routes correctly to:
{ :controller => “employees”, :department => “it”, :company =>
“exampleinc”, :lastname => “foo”, :action => “show” }

However, when using Faker to generate some basic test data, I have it
generating information with spaces, periods, and other special
characters that will undoubtedly be part of the real world for this
application. But in testing, I’ve found that when spaces, periods,
and/or other URL-encoded (or not) variables are present in the
request, the router doesn’t even route it to the controller - it just
spits out a “No Route Matches” error instead.

So for example:
get ‘/Example,+Inc./IT/Some+Last+Name’

Causes an ActionController::RoutingError: No route matches { :action
=> “show”, :company => “Example+Inc.”, :controller =>
“employees”, :lastname => “Some+Last+Name”, :department => “IT” }

What can I do differently in my routes to make this route correctly?
Thanks for any help you can provide.

I very rarely ever bump a discussion, but I’m hoping that in doing so,
some one who may have some insight who didn’t see it before, might
this time. Please forgive the shameless bump here guys, and thank you
for reading.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs