Forum: Ruby on Rails form_remote_for NOT passing param: I want put and I get post

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D48be99143e13e40d1c44a4da63a53f4?d=identicon&s=25 Mongeta 99 (raimon)
on 2009-02-10 19:40
Hello,

I'm struggling my brain with this ajax issue ...

Basically I have a form for creating records, and I want to submit it
using Ajax.

On previous versions of RoR (2.0.2) it was working, but the same methods
doesn't work on 2.2.2, and I started to make changes and changes and
read forums and the api, but no way ...

<% form_remote_for (:expedient, :url => {:action => 'create_ajax'},
:update =>'div_listd') do |f| %>

<table class="edit">
<tr>
  <td class="label" width="100px">Referencia</td>
  <td class="data"><%= f.text_field :reference %></td>
  <td><%= submit_tag "Añadir" %></td>
</tr>
</table>

<% end %>

In the development.log I only see the token param:
  Parameters:
{"authenticity_token"=>"c5fb066b9a3370e15f94154cc2140759d40f079c"}


the html source code is this:

<form action="/expedients/create_ajax" method="post" onsubmit="new
Ajax.Updater('div_listd', '/expedients/create_ajax', {asynchronous:true,
evalScripts:true, parameters:Form.serialize(this)}); return false;"><div
style="margin:0;padding:0"><input name="authenticity_token"
type="hidden" value="c5fb066b9a3370e15f94154cc2140759d40f079c" /></div>

<table class="edit">

<tr>
  <td class="label" width="100px">Referencia</td>
  <td class="data"><input id="expedient_reference"
name="expedient[reference]" size="30" type="text" /></td>
  <td><input name="commit" type="submit" value="Añadir" /></td>

</tr>

</table>

I see that the method is post, I think it should be 'PUT' to pass the
variables in the params ... or I'm wrong in this assumption ?

I tried to add the :method => :put but no way ..... sure I put it in the
wrong place :-)

thanks again!

r.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-02-10 22:05
(Received via mailing list)
On 10 Feb 2009, at 18:40, Raimon Fs wrote:

> doesn't work on 2.2.2, and I started to make changes and changes and
> read forums and the api, but no way ...
>

Random guesses: assuming that the page contains more than just this:
- are all dom ids unique
- have you got nested forms ?

Fred
D48be99143e13e40d1c44a4da63a53f4?d=identicon&s=25 Mongeta 99 (raimon)
on 2009-02-10 23:08
Frederick Cheung wrote:
> On 10 Feb 2009, at 18:40, Raimon Fs wrote:
>
>> doesn't work on 2.2.2, and I started to make changes and changes and
>> read forums and the api, but no way ...
>>
>
> Random guesses: assuming that the page contains more than just this:
> - are all dom ids unique
> - have you got nested forms ?
>
> Fred

Here is the .erb file:


<% form_remote_for (:expedient, :method => :put, :url => {:action =>
'create_ajax'}, :update =>'div_listd') do |f| %>
<%= f.error_messages %>

<table class="edit">

<tr>
  <td class="label" width="100px">Referencia</td>
  <td class="data"><%= f.text_field :reference %></td>
  <td><%= submit_tag "Añadir" %></td>
</tr>

</table>


<% end %>

<br>

<h1>Expedientes listos para ser enviados</h1>

<div id="div_listd" >
  <%= render :partial => "list" %>
</div>

<%= link_to 'General', :action => 'index' %> |
<%= link_to 'Back', expedients_path %>
This topic is locked and can not be replied to.