Phoenix Rising
2011-Feb-09 10:27 UTC
[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.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Phoenix Rising
2011-Feb-10 11:37 UTC
Re: "No Route Matches" error when certain params have URL-encoded values
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. On Feb 9, 3:27 am, Phoenix Rising <polarisris...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.