# app/avo/resources/user.rb
class Avo::Resources::User < Avo::BaseResource
  def fields
    field :comments, as: :has_many, scope: -> { query.approved }
  end
end
```

The `comments` query on the user `Index` page will have the `approved` scope attached.

<Image src="/assets/img/associations/scope.jpg" width="1660" height="830" alt="Association scope" />

With version 2.5.0, you'll also have access to the `parent` record so that you can use that to scope your associated models even better.

Starting with version 3.12, access to `resource` and `parent_resource` was additionally provided.

All the `has_many` associations have the `attach_scope` option available too.

## Show/hide buttons

You will want to control the visibility of the attach/detach/create/destroy/actions buttons visible throughout your app. You can use the policy methods to do that.

Find out more on the authorization page.

<Image src="/assets/img/associations/authorization.jpg" width="1662" height="800" alt="Associations authorization" />

<Option name="Reloadable">

<VersionReq version="3.3.6" />

The reloadable option adds a reload icon next to the association title so users can easily reload just that turbo-frame instead of doing a full page reload.

#### Usage
To enable the reloadable feature, you have two options:

1. Direct Boolean Value:

Provide a boolean value directly to the reloadable option. This sets a default behavior where the reloadable feature is either enabled or disabled based on this boolean value.

```ruby-vue
field :reviews, as: :{{ $frontmatter.field_type }}, reloadable: true
```

2. Dynamic Conditions with a Block:

For more dynamic behavior, you can provide a block to the reloadable option. Within this block, you can specify conditions under which the reloadable should be displayed.

```ruby-vue
field :reviews, as: :{{ $frontmatter.field_type }},
  reloadable: -> {
    current_user.is_admin?
  }
```

In the above example, the reloadable will be visible if the current_user is an admin.

#### ExecutionContext
The reloadable block executes within the `ExecutionContext`, granting access to all default methods and attributes.

<Image src="/assets/img/reloadable.png" width="680" height="94" alt="Reloadable" />
</Option>

<Option name="`association`">

<VersionReq version="3.6.2" />

The `for_attribute` option allows to specify the association used for a certain field. This option make possible to define same association with different scopes and different name several times on the same resource.

#### Usage
```ruby-vue
field :reviews,
  as: :{{ $frontmatter.field_type }}

field :special_reviews,
  as: :{{ $frontmatter.field_type }},
  for_attribute: :reviews,
  scope: -> { query.special_reviews }
```
</Option>

---