title: How do I loop through some nested parameters in the controller? Rails 3
body: <p>I have a 'run' object which can hold many 'layers' inside of it.  Runs accepts nested attributes for layers, but rails fails to make sure the parameters of the nested object are valid before all kinds of bad stuff happens.  I'm trying to check if the 'deposition_source_id' parameter is empty on any of the layers.  How can I loop through the layers?<br>
  This line can get the parameters from ONE or any of the layers. "0" specifies the layer.<br>
  <code>params[:run][:layers_attributes]["0"][:deposition_source_id]</code></p>
  
  <p>How can I check every layer? These are the parameters:</p>
  
  <pre><code>    =&gt; {"utf8"=&gt;"✓",
   "_method"=&gt;"put",
   "authenticity_token"=&gt;"T+X6sSda5vV19hpMZEAdf5RWSKPhJrm/q9+NXxTC5G8=",
   "run"=&gt;
    {"number"=&gt;"31310.0",
     "start_time_string"=&gt;"08/08/2012 at 11:08 AM",
     "system_id"=&gt;"4",
     "technician_id"=&gt;"4",
     "duration"=&gt;"",
     "base_pressure"=&gt;"",
     "platters"=&gt;"Apples",
     "overcoats_string"=&gt;"",
     "planetary"=&gt;"",
     "layers_attributes"=&gt;
      {"0"=&gt;
        {"deposition_source_id"=&gt;"",
         "material_id"=&gt;"60",
         "lot_id"=&gt;"118",
         "thickness_goal"=&gt;"32",
         "measured_thickness"=&gt;"3",
         "tooling_factor"=&gt;"",
         "sensor_number"=&gt;"",
         "xtal_life"=&gt;"",
         "release_agent"=&gt;"0",
         "_destroy"=&gt;"false",
         "id"=&gt;"3401"}}},
   "commit"=&gt;"Update Run",
   "action"=&gt;"update",
   "controller"=&gt;"runs",
   "id"=&gt;"2319"}
  </code></pre>