# Come aggiornare in massa i colori delle categorie?

**URL:** <https://meta.discourse.org/t/how-to-mass-update-category-colors/86873>\
**Category:** Product Support\
**Created:** [6 Maggio 2018, 12:21pm UTC](https://meta.discourse.org/t/how-to-mass-update-category-colors/86873 "2018-05-06T12:21:09Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [7 Maggio 2018, 8:20pm UTC](https://meta.discourse.org/t/how-to-mass-update-category-colors/86873/4 "2018-05-07T20:20:02Z")

</div>

The below will make child categories have the same color as their parents. This needs to be pasted into the rails console in two parts. The first will put you in a viewer to see all the categories that it found, press `q` to quit, then paste the next part. I tested it on my copy of @bartv’s import and it performed as expected.

```ruby
cats=Category.where('parent_category_id > 0')

cats.each do |cat|
  parent = Category.find(cat.parent_category_id)
  cat.color = parent.color
  cat.save!
end

```

---

_[View the full topic](https://meta.discourse.org/t/how-to-mass-update-category-colors/86873)._
