我有一个“运行”对象,其中可以容纳许多“层”。Runs 接受层的嵌套属性,但 rails 无法确保嵌套对象的参数在各种坏事发生之前是有效的。我正在尝试检查任何图层上的“deposition_source_id”参数是否为空。如何循环遍历图层?
此行可以从 ONE 或任何层获取参数。“0”指定层。
params[:run][:layers_attributes]["0"][:deposition_source_id]
如何检查每一层?这些是参数:
=> {"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"T+X6sSda5vV19hpMZEAdf5RWSKPhJrm/q9+NXxTC5G8=",
"run"=>
{"number"=>"31310.0",
"start_time_string"=>"08/08/2012 at 11:08 AM",
"system_id"=>"4",
"technician_id"=>"4",
"duration"=>"",
"base_pressure"=>"",
"platters"=>"Apples",
"overcoats_string"=>"",
"planetary"=>"",
"layers_attributes"=>
{"0"=>
{"deposition_source_id"=>"",
"material_id"=>"60",
"lot_id"=>"118",
"thickness_goal"=>"32",
"measured_thickness"=>"3",
"tooling_factor"=>"",
"sensor_number"=>"",
"xtal_life"=>"",
"release_agent"=>"0",
"_destroy"=>"false",
"id"=>"3401"}}},
"commit"=>"Update Run",
"action"=>"update",
"controller"=>"runs",
"id"=>"2319"}