I think I''m not the first to ask this question. I have a fields_for within a form_remote_for and this not work properly , the remote_form_for serialize strangely all params passed by fields_for. with a form_for it''s work perfectly. Rails -v = 2.3.8 any help ? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2010-Jul-04 16:58 UTC
Re: fields_for and form_remote_for not work properly
On Jul 4, 5:53 pm, fmh <helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I think I''m not the first to ask this question. > > I have a fields_for within a form_remote_for and this not work > properly , the remote_form_for serialize strangely all params passed > by fields_for. >What do the params look like ? What does your form look like ? Fred> with a form_for it''s work perfectly. > > Rails -v = 2.3.8 > > any help ?-- 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.
/////////// Partial
<%= error_messages_for :company %>
<% form_remote_for :company , :url =>{:action
=> :update_notif} , :html=>{} do |f| -%>
<div id="notifications">
<%= add_notification_link("Add notification") %>
<table class="list">
<tr id="tr_id_1"><th>Email</th><th
colspan="2">Label</th></tr>
<%= render :partial => "companies/notification" ,
:collection =>
@company.notifications%>
</table>
</div>
<%= f.submit "Save"%>
<%end%>
////////// _notification.html.erb
<% new_or_existing = notification.new_record? ? ''new'' :
''existing'' %>
<% prefix = "company[#{new_or_existing}_notification_attributes][]"
%>
<% fields_for prefix, notification do |notification_form| -%>
<tr>
<td>
<% id = new_or_existing == "new" ?
"company_new_notification_attributes_email" : nil %>
<%= notification_form.text_field_with_auto_complete :email,
{:id=> id} ,
{:url =>
{:controller=>:autocompletes ,
:action=>"for_company_notifications_email"},
:method => :get,
:frequency=>0.2,
:skip_style => true,
:select =>"email",
:with => "''text_field_val='' +
element.value"
}
%>
</td>
<td>
<%= notification_form.text_field(:label) %>
</td>
<td>
<% if new_or_existing == "new" %>
<%= link_to_function "<img
src=''/images/delete.png''>", "$
(this).up(''tr'').remove()" %>
<% else %>
<%= link_to_delete :notifications,:destroy,notification.id %>
<%end%>
</td>
</tr>
<% end -%>
On 4 juil, 18:58, Frederick Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> On Jul 4, 5:53 pm, fmh
<helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > I think I''m not the first to ask this question.
>
> > I have a fields_for within a form_remote_for and this not work
> > properly , the remote_form_for serialize strangely all params passed
> > by fields_for.
>
> What do the params look like ? What does your form look like ?
>
> Fred
>
> > with a form_for it''s work perfectly.
>
> > Rails -v = 2.3.8
>
> > any help ?
--
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.
any help? On 4 juil, 19:29, fmh <helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> /////////// Partial > <%= error_messages_for :company %> > <% form_remote_for :company , :url =>{:action > => :update_notif} , :html=>{} do |f| -%> > <div id="notifications"> > <%= add_notification_link("Add notification") %> > <table class="list"> > <tr id="tr_id_1"><th>Email</th><th colspan="2">Label</th></tr> > <%= render :partial => "companies/notification" , :collection => > @company.notifications%> > </table> > </div> > <%= f.submit "Save"%> > > <%end%> > > ////////// _notification.html.erb > > <% new_or_existing = notification.new_record? ? ''new'' : ''existing'' %> > <% prefix = "company[#{new_or_existing}_notification_attributes][]" %> > <% fields_for prefix, notification do |notification_form| -%> > > <tr> > <td> > <% id = new_or_existing == "new" ? > "company_new_notification_attributes_email" : nil %> > <%= notification_form.text_field_with_auto_complete :email, > {:id=> id} , > {:url => > {:controller=>:autocompletes , :action=>"for_company_notifications_email"}, > :method => :get, > :frequency=>0.2, > :skip_style => true, > :select =>"email", > :with => "''text_field_val='' + element.value" > } > %> > </td> > <td> > <%= notification_form.text_field(:label) %> > </td> > <td> > <% if new_or_existing == "new" %> > <%= link_to_function "<img src=''/images/delete.png''>", "$ > (this).up(''tr'').remove()" %> > <% else %> > <%= link_to_delete :notifications,:destroy,notification.id %> > > <%end%> > </td> > </tr> > <% end -%> > > On 4 juil, 18:58, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Jul 4, 5:53 pm, fmh <helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I think I''m not the first to ask this question. > > > > I have a fields_for within a form_remote_for and this not work > > > properly , the remote_form_for serialize strangely all params passed > > > by fields_for. > > > What do the params look like ? What does your form look like ? > > > Fred > > > > with a form_for it''s work perfectly. > > > > Rails -v = 2.3.8 > > > > any help ?-- 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.
any help? On 4 juil, 19:29, fmh <helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> /////////// Partial > <%= error_messages_for :company %> > <% form_remote_for :company , :url =>{:action > => :update_notif} , :html=>{} do |f| -%> > <div id="notifications"> > <%= add_notification_link("Add notification") %> > <table class="list"> > <tr id="tr_id_1"><th>Email</th><th colspan="2">Label</th></tr> > <%= render :partial => "companies/notification" , :collection => > @company.notifications%> > </table> > </div> > <%= f.submit "Save"%> > > <%end%> > > ////////// _notification.html.erb > > <% new_or_existing = notification.new_record? ? ''new'' : ''existing'' %> > <% prefix = "company[#{new_or_existing}_notification_attributes][]" %> > <% fields_for prefix, notification do |notification_form| -%> > > <tr> > <td> > <% id = new_or_existing == "new" ? > "company_new_notification_attributes_email" : nil %> > <%= notification_form.text_field_with_auto_complete :email, > {:id=> id} , > {:url => > {:controller=>:autocompletes , :action=>"for_company_notifications_email"}, > :method => :get, > :frequency=>0.2, > :skip_style => true, > :select =>"email", > :with => "''text_field_val='' + element.value" > } > %> > </td> > <td> > <%= notification_form.text_field(:label) %> > </td> > <td> > <% if new_or_existing == "new" %> > <%= link_to_function "<img src=''/images/delete.png''>", "$ > (this).up(''tr'').remove()" %> > <% else %> > <%= link_to_delete :notifications,:destroy,notification.id %> > > <%end%> > </td> > </tr> > <% end -%> > > On 4 juil, 18:58, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Jul 4, 5:53 pm, fmh <helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I think I''m not the first to ask this question. > > > > I have a fields_for within a form_remote_for and this not work > > > properly , the remote_form_for serialize strangely all params passed > > > by fields_for. > > > What do the params look like ? What does your form look like ? > > > Fred > > > > with a form_for it''s work perfectly. > > > > Rails -v = 2.3.8 > > > > any help ?-- 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.
with form_for :
Parameters:
{"company"=>{"new_notification_attributes"=>[{"label"=>"",
"email"=>""}, {"label"=>"",
"email"=>""}],
"existing_notification_attributes"=>{"3"=>{"label"=>"test",
"email"=>"test-J0of1frlU80@public.gmane.org"}}}
with form_remote_for :
Parameters:
{"company"=>{"new_notification_attributes"=>[{"label"=>""},
{ "email"=>""}, {"label"=>""},
{"email"=>""}],
"existing_notification_attributes"=>{"3"=>{"label"=>"test",
"email"=>"test-J0of1frlU80@public.gmane.org"}}}
????
On 5 juil, 10:50, fmh
<helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> any help?
>
> On 4 juil, 19:29, fmh
<helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > /////////// Partial
> > <%= error_messages_for :company %>
> > <% form_remote_for :company , :url =>{:action
> > => :update_notif} , :html=>{} do |f| -%>
> > <div id="notifications">
> > <%= add_notification_link("Add notification") %>
> > <table class="list">
> > <tr
id="tr_id_1"><th>Email</th><th
colspan="2">Label</th></tr>
> > <%= render :partial => "companies/notification"
, :collection =>
> > @company.notifications%>
> > </table>
> > </div>
> > <%= f.submit "Save"%>
>
> > <%end%>
>
> > ////////// _notification.html.erb
>
> > <% new_or_existing = notification.new_record? ?
''new'' : ''existing'' %>
> > <% prefix =
"company[#{new_or_existing}_notification_attributes][]" %>
> > <% fields_for prefix, notification do |notification_form| -%>
>
> > <tr>
> > <td>
> > <% id = new_or_existing == "new" ?
> > "company_new_notification_attributes_email" : nil %>
> > <%= notification_form.text_field_with_auto_complete :email,
> > {:id=> id} ,
> > {:url =>
> > {:controller=>:autocompletes ,
:action=>"for_company_notifications_email"},
> > :method => :get,
> > :frequency=>0.2,
> > :skip_style => true,
> > :select =>"email",
> > :with => "''text_field_val='' +
element.value"
> > }
> > %>
> > </td>
> > <td>
> > <%= notification_form.text_field(:label) %>
> > </td>
> > <td>
> > <% if new_or_existing == "new" %>
> > <%= link_to_function "<img
src=''/images/delete.png''>", "$
> > (this).up(''tr'').remove()" %>
> > <% else %>
> > <%= link_to_delete :notifications,:destroy,notification.id
%>
>
> > <%end%>
> > </td>
> > </tr>
> > <% end -%>
>
> > On 4 juil, 18:58, Frederick Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > On Jul 4, 5:53 pm, fmh
<helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > I think I''m not the first to ask this question.
>
> > > > I have a fields_for within a form_remote_for and this not
work
> > > > properly , the remote_form_for serialize strangely all
params passed
> > > > by fields_for.
>
> > > What do the params look like ? What does your form look like ?
>
> > > Fred
>
> > > > with a form_for it''s work perfectly.
>
> > > > Rails -v = 2.3.8
>
> > > > any help ?
--
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.
with form_for :
Parameters:
{"company"=>{"new_notification_attributes"=>[{"label"=>"",
"email"=>""}, {"label"=>"",
"email"=>""}],
"existing_notification_attributes"=>{"3"=>{"label"=>"test",
"email"=>"test-J0of1frlU80@public.gmane.org"}}}
with form_remote_for :
Parameters:
{"company"=>{"new_notification_attributes"=>[{"label"=>""},
{ "email"=>""}, {"label"=>""},
{"email"=>""}],
"existing_notification_attributes"=>{"3"=>{"label"=>"test",
"email"=>"test-J0of1frlU80@public.gmane.org"}}}
????
On 5 juil, 10:50, fmh
<helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> any help?
>
> On 4 juil, 19:29, fmh
<helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > /////////// Partial
> > <%= error_messages_for :company %>
> > <% form_remote_for :company , :url =>{:action
> > => :update_notif} , :html=>{} do |f| -%>
> > <div id="notifications">
> > <%= add_notification_link("Add notification") %>
> > <table class="list">
> > <tr
id="tr_id_1"><th>Email</th><th
colspan="2">Label</th></tr>
> > <%= render :partial => "companies/notification"
, :collection =>
> > @company.notifications%>
> > </table>
> > </div>
> > <%= f.submit "Save"%>
>
> > <%end%>
>
> > ////////// _notification.html.erb
>
> > <% new_or_existing = notification.new_record? ?
''new'' : ''existing'' %>
> > <% prefix =
"company[#{new_or_existing}_notification_attributes][]" %>
> > <% fields_for prefix, notification do |notification_form| -%>
>
> > <tr>
> > <td>
> > <% id = new_or_existing == "new" ?
> > "company_new_notification_attributes_email" : nil %>
> > <%= notification_form.text_field_with_auto_complete :email,
> > {:id=> id} ,
> > {:url =>
> > {:controller=>:autocompletes ,
:action=>"for_company_notifications_email"},
> > :method => :get,
> > :frequency=>0.2,
> > :skip_style => true,
> > :select =>"email",
> > :with => "''text_field_val='' +
element.value"
> > }
> > %>
> > </td>
> > <td>
> > <%= notification_form.text_field(:label) %>
> > </td>
> > <td>
> > <% if new_or_existing == "new" %>
> > <%= link_to_function "<img
src=''/images/delete.png''>", "$
> > (this).up(''tr'').remove()" %>
> > <% else %>
> > <%= link_to_delete :notifications,:destroy,notification.id
%>
>
> > <%end%>
> > </td>
> > </tr>
> > <% end -%>
>
> > On 4 juil, 18:58, Frederick Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > On Jul 4, 5:53 pm, fmh
<helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > I think I''m not the first to ask this question.
>
> > > > I have a fields_for within a form_remote_for and this not
work
> > > > properly , the remote_form_for serialize strangely all
params passed
> > > > by fields_for.
>
> > > What do the params look like ? What does your form look like ?
>
> > > Fred
>
> > > > with a form_for it''s work perfectly.
>
> > > > Rails -v = 2.3.8
>
> > > > any help ?
--
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.
Frederick Cheung
2010-Jul-05 15:55 UTC
Re: fields_for and form_remote_for not work properly
On Jul 5, 3:10 pm, fmh <helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> with form_for : > > Parameters: {"company"=>{"new_notification_attributes"=>[{"label"=>"", > "email"=>""}, {"label"=>"", "email"=>""}], > "existing_notification_attributes"=>{"3"=>{"label"=>"test", > "email"=>"t...-J0of1frlU80@public.gmane.org"}}} >Have you had a look at the actual body of the post (ie before rails tries to parse it)? at a guess it looks like prototype may be serializing the form in an unexpected way. Can you reduce this to a minimal test case ? Fred> with form_remote_for : > > Parameters: {"company"=>{"new_notification_attributes"=>[{"label"=>""}, > { "email"=>""}, {"label"=>""}, {"email"=>""}], > "existing_notification_attributes"=>{"3"=>{"label"=>"test", > "email"=>"t...-J0of1frlU80@public.gmane.org"}}} > > ???? > > On 5 juil, 10:50, fmh <helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > any help? > > > On 4 juil, 19:29, fmh <helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > /////////// Partial > > > <%= error_messages_for :company %> > > > <% form_remote_for :company , :url =>{:action > > > => :update_notif} , :html=>{} do |f| -%> > > > <div id="notifications"> > > > <%= add_notification_link("Add notification") %> > > > <table class="list"> > > > <tr id="tr_id_1"><th>Email</th><th colspan="2">Label</th></tr> > > > <%= render :partial => "companies/notification" , :collection => > > > @company.notifications%> > > > </table> > > > </div> > > > <%= f.submit "Save"%> > > > > <%end%> > > > > ////////// _notification.html.erb > > > > <% new_or_existing = notification.new_record? ? ''new'' : ''existing'' %> > > > <% prefix = "company[#{new_or_existing}_notification_attributes][]" %> > > > <% fields_for prefix, notification do |notification_form| -%> > > > > <tr> > > > <td> > > > <% id = new_or_existing == "new" ? > > > "company_new_notification_attributes_email" : nil %> > > > <%= notification_form.text_field_with_auto_complete :email, > > > {:id=> id} , > > > {:url => > > > {:controller=>:autocompletes , :action=>"for_company_notifications_email"}, > > > :method => :get, > > > :frequency=>0.2, > > > :skip_style => true, > > > :select =>"email", > > > :with => "''text_field_val='' + element.value" > > > } > > > %> > > > </td> > > > <td> > > > <%= notification_form.text_field(:label) %> > > > </td> > > > <td> > > > <% if new_or_existing == "new" %> > > > <%= link_to_function "<img src=''/images/delete.png''>", "$ > > > (this).up(''tr'').remove()" %> > > > <% else %> > > > <%= link_to_delete :notifications,:destroy,notification.id %> > > > > <%end%> > > > </td> > > > </tr> > > > <% end -%> > > > > On 4 juil, 18:58, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Jul 4, 5:53 pm, fmh <helmi.fatna...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > I think I''m not the first to ask this question. > > > > > > I have a fields_for within a form_remote_for and this not work > > > > > properly , the remote_form_for serialize strangely all params passed > > > > > by fields_for. > > > > > What do the params look like ? What does your form look like ? > > > > > Fred > > > > > > with a form_for it''s work perfectly. > > > > > > Rails -v = 2.3.8 > > > > > > any help ?-- 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.