Remco Hh wrote:
hi i have a weird problem:
this is my view:
<tr>
<%= start_form_tag :action => 'new_beschikbaarheid', :behandelaar_id
=>@behandelaar, :year => @year%>
<td>behandelaar</td><td><%=
collection_select("behandelaar",'id',Behandelaar.find(:all),:id,:naam)
%>
<%= submit_tag 'Opzoeken' %>
</td>
<%= end_form_tag %>
when i hit the submit button i get this url:
http://localhost:3000/admin/new_beschikbaarheid?behandelaar_id=1&year=2006
where does the amp sign come from and better: how can i get rid of it:
i sure hope someone can help me, i don't know what to do anymore....
This is a known problem with some of the tag helpers that handle URLs
-- they double-escape the URL so that & becomes &amp; instead of
just & in the HTML.
I've written a patch to fix this, but it's not been accepted yet:
http://dev.rubyonrails.org/ticket/5928
In the meantime you could work around it with some ugly code like this:
<form action="<%= url_for(:action => 'new_beschikbaarheid',
:behandelaar_id
=>@behandelaar, :year => @year) %>">
Alternatively you could write yourself a custom route so that the
generated URL doesn't contain any ampersands:
map.connect ':controller/new_beschikbaarheid/:behandellar_id/:year'
or something like that.
Chris
Chris Mear wrote:
In the meantime you could work around it with some ugly code like this:
<form action="<%= url_for(:action => 'new_beschikbaarheid',
:behandelaar_id
> =>@behandelaar, :year => @year) %>">
Google Groups ate my code! But you get the idea -- just manually write
the form tag, and call url_for to write the action attribute.
Chris
Remco Hh wrote:
> hi i have a weird problem:
<...>
> when i hit the submit button i get this url:
>
> http://localhost:3000/admin/new_beschikbaarheid?behandelaar_id=1&year=2006
Chris Mear:
<...>
In the meantime you could work around it with some ugly code like this:
<form action="<%= url_for(:action => 'new_beschikbaarheid',
:behandelaar_id
> =>@behandelaar, :year => @year) %>">
Alternatively you could write yourself a custom route so that the
generated URL doesn't contain any ampersands:
map.connect ':controller/new_beschikbaarheid/:behandellar_id/:year'
or something like that.
This bug should be fixed, but I'd suggest not to mix GET and POST
(default) methods anyway. You can use hidden fields for additional
parameters:
<tr>
<%= start_form_tag :action => 'new_beschikbaarheid'%>
<%= hidden_field_tag :behandelaar_id, @behandelaar %>
<%= hidden_field_tag :year, @year %>
<td>behandelaar</td><td><%=
collection_select("behandelaar",'id',Behandelaar.find(:all),:id,:naam)
%>
<%= submit_tag 'Opzoeken' %>
</td>
<%= end_form_tag %>
Regards,
Rimantas
Rimantas Liubertas wrote:
I'd suggest not to mix GET and POST
(default) methods anyway. You can use hidden fields for additional
parameters:
You're not mixing GET and POST; you're just POSTing to a URL that
happens to have some querystring parameters. And, with Rails' routes,
the difference between
/user/edit/1
and
user/edit?id=1
is pretty slender. They both end up as params[:id] = 1. So every time
you submit a form to /user/edit/1 (which is standard practice in
Rails), you're effectively POSTing to a URL with querystring
parameters; it's just that routing hides the ugliness of ?s, =s and &s.
Chris
Rimantas Liubertas wrote:
> I'd suggest not to mix GET and POST
> (default) methods anyway. You can use hidden fields for additional
> parameters:
You're not mixing GET and POST; you're just POSTing to a URL that
happens to have some querystring parameters. And, with Rails' routes,
the difference between
My bad, I should have said "I'd suggest to avoid passing parameters in url
with POST" 
Regards,
Rimantas