Routes not working when submitting a form

Hi,

I have the following code, a very basic textfield with a submit button:

<%= form_tag({:controller => “job”, :action => “index”}, :method =>
‘get’) %>
<%= text_field_tag ‘province’, @province %>
<%= submit_tag “search” %>
<%= end_form_tag %>

In my routes.rb file I have:

map.connect ‘job/:province’, :controller => ‘job’, :action => ‘index’

So now when I submit the form I suspect the URL to become
http://localhost:3000/job/1, but instead it becomes
http://localhost:3000/?province=1&commit=zoeken. Does anybody know how I
can get it to become the first URL. I really need this, because
otherwise, the whole caching system breaks. Thanks.

Kind regards,

Nick

Nick S. wrote:

Hi,

I have the following code, a very basic textfield with a submit button:

<%= form_tag({:controller => “job”, :action => “index”}, :method =>
‘get’) %>
<%= text_field_tag ‘province’, @province %>
<%= submit_tag “search” %>
<%= end_form_tag %>

In my routes.rb file I have:

map.connect ‘job/:province’, :controller => ‘job’, :action => ‘index’

So now when I submit the form I suspect the URL to become
http://localhost:3000/job/1, but instead it becomes
http://localhost:3000/?province=1&commit=zoeken. Does anybody know how I
can get it to become the first URL. I really need this, because
otherwise, the whole caching system breaks. Thanks.

Kind regards,

Nick

The problem is browser side. It sees a form action of “/job” and just
tacks the get params onto it.

Maybe you could use javascript to alter the action of the form.

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