On Dec 11, 9:17 am, Fresh Mix
<li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> 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:
>
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
> 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
>
> --
> Posted viahttp://www.ruby-forum.com/.
--
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.