app/controllers/servers_controller.rb
def server_params
    # `installed_software: []` permits arrays
    params.require(:server).permit(:name, :cpu_cores, :ram_gb, :storage_gb, :ipv4_address,
                                   :ipv6_address, :mac_address, :fqdn, {installed_software: []},
                                   :model, :vendor, :description, :responsible_id, sudo_user_ids: [], user_ids: [])
    # Remove empty software form fields
    # https://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-each_pair
    params[:server].each { |k,v| v.reject!(&:blank?) if k.eql?('installed_software') }
  end
# Never trust parameters from the scary internet, only allow the white list through.
Never trust parameters from the scary internet, only allow the white list through.
Never trust parameters from the scary internet only allow the white list through .
def server_params
    params.require(:server).permit(:name, :cpu_cores, :ram_gb, :storage_gb, :ipv4_address,
                                   :ipv6_address, :mac_address, :fqdn, {installed_software: []},
                                   :model, :vendor, :description, :responsible_id, sudo_user_ids: [], user_ids: [])
    params[:server].each { |k,v| v.reject!(&:blank?) if k.eql?('installed_software') }
  end
def server_params params . require ( :server ) . permit ( :name , :cpu_cores , :ram_gb , :storage_gb , :ipv4_address , :ipv6_address , :mac_address , :fqdn , { installed_software : [ ] } , :model , :vendor , :description , :responsible_id , sudo_user_ids : [ ] , user_ids : [ ] ) params [ :server ] . each { | k , v | v . reject! ( & :blank? ) if k . eql? ( 'installed_software' ) } end
Never trust parameters from the scary internet, only allow the white list through.
Never trust parameters from the scary internet only allow the white list through .
# `installed_software: []` permits arrays # Remove empty software form fields # https://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-each_pair