---
# System prepended metadata

title: Chef Supermarket
tags: [support, chef, supermarket]

---

# Chef Supermarket

###### tags: `support` `supermarket` `chef`

## Console access

```bash
supermarket-ctl console
```

## Changing owner on multiple cookbooks

```ruby
admin_user_making_this_change = User.with_username('me').first
old_owner = User.with_username('Jorge').first
new_owner = User.with_username('Julia').first
old_owner_should_remain_a_collaborator = false

cookbooks_to_transfer = Cookbook.where(owner: old_owner)

cookbooks_to_transfer.each do |cb|
  cookbook.transfer_ownership(admin_user_making_this_change, new_owner, old_owner_should_remain_a_collaborator)
end
```

## Adding collaborators to all cookbooks

```ruby
collaborator_user = User.with_username('Jorge').first
cookbooks = Cookbook.all

cookbooks.each do |cb|
  collaborator = Collaborator.new(
    user_id: collaborator_user.id,
    resourceable: cb,
    group_id: nil
  )
  collaborator.save!
end
```