aq1018/mongoid_taggable_with_context — Issue #15: No clean_up on tags_array=
Author: yeggeps
Created: 2012-02-21 15:37:42+00:00
State: open

The method

```
def clean_up_array(ary = [])
# 0). remove all nil values
# 1). strip all white spaces. Could leave blank strings (e.g. foo, , bar, baz)
# 2). remove all blank strings
# 3). remove duplicate
ary.compact.map(&:strip).reject(&:blank?).uniq
end
```

Is only run when setting values trough tags= but not tags_array=
This results in nil/empty/duplicate values being stored, they are however cleaned out when accessing trough the tags_field getter:

tags_array: ["", "delivery"]
tags: "delivery"

Guess it would be something like this:

```
def #{tags_array_field}=(ary)
write_attribute(:#{tags_array_field}, clean_up_array(ary))
end
```