Nothing obviously wrong in your code (AFAIK, which isn't very far ;-).  What 
does the HTML that gets generated look like?  Are the name attributes of your 
form_for generated input items things like: 
customer_account[events][][is_active]?

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 
Nathan R
Sent: Tuesday, September 16, 2008 10:17 AM
To: Ruby on Rails: Talk
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [Rails] fields for grouping problem


So I am having a weird issue that I hope someone else has run into and knows 
how to fix.  Basically, I have a partial which includes a fields_for call that 
renders a form for a specific type of object.
This partial can be rendered multiple times on a page if the user wants to add 
multiple of these objects.  However, when the submit button is clicked, the 
grouping of the objects parameters are inconsistent with how they are entered.

The result of trying to create two of these "event" objects follows:

Here is what the params hash contains on the request:

 "events"=>[{"event_type_id"=>"3"},
 {"event_type_id"=>"3",
 "is_active"=>"true"},
 {"is_active"=>"true",
 "user_id"=>"1"},
 {"eta"=>"September 22,
 2008 1:11 PM",
 "user_id"=>"1"},
 {"description"=>"Milestone 1 criteria",  "eta"=>"September 23,
 2008 1:11 PM"},
 {"description"=>"Milestone 2 criteria",  "risk_level_id"=>"1"},  
{"risk_description"=>"Milestone 1 risk detail",  "risk_level_id"=>"2"},  
{"risk_description"=>"Milestone 2 risk detail"}]},  "commit"=>"Submit Changes", 
 "authenticity_token"=>"af7a84442defabeeda94dac616930e9a3ee514d7",
 "id"=>"119"}


This is where the Partial is called in the view:

<div id="add_milestone">
</div>
    <%= add_milestone_link("Add a Milestone")%>


This is the helper method:

  def add_milestone_link(name)
    link_to_function name do |page|
      page.insert_html :bottom,
                       :add_milestone,
                       :partial=>'/customer_accounts/edit_page/
add_milestone_event',
                       :locals=>{:customer_account_id => @customer_account.id, 
:event=>Event.new}
    end
  end

This is the partial:

<div id="add_milestone">

    <% fields_for "customer_account[events][]", event do |events_form| %>

   <table class="account">
    <tr>
        <td >Milestone </td>
        <%= events_form.hidden_field(:event_type_id, :value =>

EventType.find_event_type_id_by_description("Milestone")) %>
        <%= events_form.hidden_field(:is_active, :value => true) %>
       <%= events_form.hidden_field(:user_id, :value =>
@current_user.id) %>
       <td ><%=events_form.calendar_date_select(:eta) </td>
       <td ><%= events_form.text_area(:description, :rows => 2, :class => 
"full-width") %></td>
        <td > <%= events_form.collection_select(:risk_level_id,
RiskLevel.find(:all), :id, :value, {:prompt => "- Select One -"}, 
:class=>"full-width") %> </td>
        <td><%=  events_form.text_area(:risk_description, :rows => 2, :class => 
"full-width") %></td>
     </tr>

   </table>

<% end %>

</div>






Any help would be greatly appreciated as we have a similar problem elsewhere in 
the code and the reason for this error should provide us with the insight to 
fix that one as well 

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to