# app/avo/resources/course_link.rb
class Avo::Resources::CourseLink < Avo::BaseResource
  self.search = {
    query: -> {
      query.ransack(id_eq: q, link_cont: q, m: "or").result(distinct: false)
    }
  }
end
```

#### Default

`false`

#### Possible values

`true`, `false`
</Option>

<Option name="`attach_scope`">

Scope out the records the user sees on the Attach modal.

#### Default

`nil`

#### Possible values

```ruby{3}
field :user,
  as: :belongs_to,
  attach_scope: -> { query.non_admins }
```

Pass in a block where you attach scopes to the `query` object and `parent` object, which is the actual record where you want to assign the association. The block is executed in the `ExecutionContext`.
</Option>

:::warning
The `attach_scope` will not filter the records in the listing from `has_many` or `has_and_belongs_to_many` associations.
Use [`scope`](#scope) or a Pundit policy `Scope` for that.
:::

```ruby-vue{3}
field :members,
  as: :{{ $frontmatter.field_type }},
  attach_scope: -> { query.where.not(team_id: parent.id) }
  ```
In this example, in the `attach_scope`, we ensure that when attaching members to a team, only those who are not already members will appear in the list of options.

## Show on edit screens

By default, the `{{ $frontmatter.field_type }}` field is only visible in the show view. To make it available in the edit view as well, include the `show_on: :edit` option. This ensures that the `{{ $frontmatter.field_type }}` show view component is also rendered within the edit view.

## Nested in Forms
<div class="space-x-2">
  <VersionReq version="3.19.0"/>
  <BetaStatus label="Public beta"/>
  <LicenseReq license="advanced"/>
</div>

You can use ["Show on edit screens"](#show-on-edit-screens) to make the `{{ $frontmatter.field_type }}` field available in the edit view. However, this will render it using the show view component.

To enable nested creation for the `{{ $frontmatter.field_type }}` field, allowing it to be created and / or edited alongside its parent record within the same form, use the `nested` option which is a hash with configurable option.

Keep in mind that this will display the field’s resource as it appears in the edit view.

<Option name="nested">

Enables this field as a nested form in the specified views.

##### Default value

`{}`

#### Possible values

A hash with the following options:
- `on:` Views in which to enable nesting. Accepted values:
  - `:new` - Enables nesting in the new view.
  - `:edit` - Enables nesting in the edit view.
  - `:forms` - Enables nesting in the new and edit views.
- `limit:` *(Only for `has_many` and `has_and_belongs_to_many` fields)* Hides the "Add" button when the specified limit is reached.

:::tip
Setting `nested: true` is a shortcut for `nested: { on: :forms }`.
:::

#### Example

```ruby-vue{4,5,7,8,10,11,13-14,16-19}