Router problem

I have a router:

match “/person(/:sex)(/:search)” => “person#index”, :constraints => {
:sex => /male|female/ }

And a search form:

<%= form_tag("/person", :method => “get”) do %>
<%= search_field_tag(:search, params[:search]) %>
<%= submit_tag(“Search”) %>
<% end %>

But why, after submit form url is:

http://localhost:3000/person?utf8=✓&search=Clinton&commit=Search

And not a:

http://localhost:3000/person/Clinton

or

http://localhost:3000/person/Clinton?utf8=✓&commit=Search

The “sex” is optional value and url should be only

http://localhost:3000/person/Clinton

or

http://localhost:3000/person/male/Clinton

On Dec 11, 9:17 am, Fresh M. [email protected] wrote:

<% end %>

But why, after submit form url is:

Your browser constructs the URL from the form. It doesn’t know
anything about routes so will always just use the URL specified in the
form’s action attribute, either appending the query string or sticking
it in the request body depending on whether it’s a get or a post.

Fred

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