alphagov/panopticon — pull request #116 by JordanHatch (2014-01-28 14:36:47+00:00)
Title: Correctly handle nil values for tag array fields

There's a bug in Rails where parameters that are an empty array get changed to be nil before being passed to the controller. This breaks requests passing in an empty array of tags as the nil gets passed down into the set_tags_of_type Taggable method, causing an exception in Mongo.

This fixes the behaviour so that a nil value for a field matching the tag types will get replaced with an empty array. This only applies to fields which have a key present in the params hash, to make sure we don't overwrite tags of every type.