# app/policies/course_policy.rb
class CoursePolicy < ApplicationPolicy
  def view_attendees? = true
end
```

For more details, refer to the view_{association}? documentation.
:::

### Example 2: Array field fetching data from the model's method

If no block is defined, Avo will attempt to fetch data by calling the corresponding method on the model:

```ruby
class Course < ApplicationRecord
  def attendees
    User.all.first(6) # Example fetching first 6 users
  end
end
```

Here, the `attendees` field will use the `attendees` method from the `Course` model to render its data dynamically.

### Example 3: Fallback to the `records` method

If neither the block nor the model's method exists, Avo will fall back to the `records` method defined in the resource used to render the array field. This is useful for providing a default dataset.

When neither a block nor a model's method is defined, Avo will fall back to the `records` method in the resource used to render the field. This is a handy fallback for providing default datasets:

```ruby
class Avo::Resources::Attendee < Avo::Resources::ArrayResource
  def records
    [
      { id: 1, name: "Default Attendee", role: "Guest", organization: "DefaultOrg" }
    ]
  end
end
```

## Summary of Data Fetching Hierarchy

When using `has_many` with `array: true`, Avo will fetch data in the following order:
1. Use data returned by the **block** provided in the field.
2. Fetch data from the **associated model method** (e.g., `Course#attendees`).
3. Fall back to the **`records` method** defined in the resource.

This hierarchy provides maximum flexibility and ensures seamless integration with both dynamic and predefined datasets.

---