Rails 4 Multiple Nested Forms and Strong Parameters -



Rails 4 Multiple Nested Forms and Strong Parameters -

i using rails 4 , nested forms , strong parameters.

i need update multiple models 1 form.

this how declaring strong parameters. parent controller. associations has_many , belongs_to going in order rundatum->material->particlesize

def rundatum_params params.require(:rundatum).permit( :material, :company_id, :material_density, :feed_moisture, :date, :building, :machine, :material_weight, :time_mins, :rate_lb_hr, :mill_amps, :class_amps, :mill_liner, :beater_plate_size, :mill_rpm, :class_rpm, :feeder_type, :feeder_setting, :feeder_aug_diameter, :tlgs_set, :air_pressure, :temp_mill_out, :temp_prod_out, :temp_ambient, materials_attributes: [:id, :name, :density, :msds_url, :moisture, :notes, :_destroy], particle_sizes_attributes: [:id, :screen, :percent_through, :percent_retained, :_destroy]) end

the output rails server is:

rundatum load (0.6ms) select "rundata".* "rundata" "rundata"."id" = $1 limit 1 [["id", 7]] unpermitted parameters: particle_sizes_attributes

what way declare strong parameters when updating multiple models 1 form?

thanks

if have particlesize nested within material, should nest parameters well.

def rundatum_params params.require(:rundatum).permit( :material, :company_id, :material_density, :feed_moisture, :date, :building, :machine, :material_weight, :time_mins, :rate_lb_hr, :mill_amps, :class_amps, :mill_liner, :beater_plate_size, :mill_rpm, :class_rpm, :feeder_type, :feeder_setting, :feeder_aug_diameter, :tlgs_set, :air_pressure, :temp_mill_out, :temp_prod_out, :temp_ambient, { materials_attributes: [:id, :name, :density, :msds_url, :moisture, :notes, :_destroy, { particle_sizes_attributes: [:id, :screen, :percent_through, :percent_retained, :_destroy] }] }) end

ruby-on-rails-4 nested-forms strong-parameters

Comments

Popular posts from this blog

javascript - I need to update the text of a paragraph by inline edit -

javascript - THREE.js reposition vertices for RingGeometry -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -