public
Created

Put "repair_empty_param_associations" in your before filters in the application_controller.rb

  • Download Gist
rails 3.2.11 params patch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
def repair_empty_param_associations
params.keys.each do |key|
repair_nested_params(params, key, params[key])
end
end
 
private
 
def repair_nested_params(current_params, key, value)
if key =~ /^(.*)_attributes$/ && value.nil?
current_params[key] = []
elsif value.is_a? Hash
value.keys.each do |nested_key|
repair_nested_params(value, nested_key, value[nested_key])
end
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.