# Or as hash:
self.pagination = {
  type: :default,
  size: [1, 2, 2, 1],
}
```

The exposed pagination setting above have the default value for each key.

### `type`<br><br>
  #### Possible values
  `:default`, `:countless`
  #### Default
  `:default`

### `size`<br><br>
  #### Possible values
  [Pagy docs - Control the page links](https://ddnexus.github.io/pagy/docs/how-to/#control-the-page-links)
  #### Default
  `[1, 2, 2, 1]` - before <Version version="3.11.5" />

  `9` - <VersionReq version="3.11.5" />

### Examples
#### Default
```ruby
self.pagination = -> do
  {
    type: :default,
    size: [1, 2, 2, 1],
  }
end
```

<Image src="/assets/img/resources/pagination/default.png" width="1025" height="65" alt="Default pagination" />
<br><br>

#### Countless

```ruby
self.pagination = -> do
  {
    type: :countless
  }
end
```

<Image src="/assets/img/resources/pagination/countless.png" width="1030" height="67" alt="Countless pagination" />
<br><br>

#### Countless and "pageless"
```ruby
self.pagination = -> do
  {
    type: :countless,
    size: []
  }
end
```
<Image src="/assets/img/resources/pagination/countless_empty_size.png" width="1029" height="62" alt="Countless pagination size empty" />
</Option>

<Option name="`cache_hash`">

The `cache_hash` method is used to compute the cache key for each row. The method looks something like this:

```ruby
def cache_hash(parent_record)
  result = [record, file_hash]

  if parent_record.present?
    result << parent_record
  end

  result
end

def file_hash
  content_to_be_hashed = ""

  file_name = self.class.underscore_name.tr(" ", "_")
  resource_path = Rails.root.join("app", "avo", "resources", "#{file_name}.rb").to_s
  if File.file? resource_path
    content_to_be_hashed += File.read(resource_path)
  end

  # policy file hash
  policy_path = Rails.root.join("app", "policies", "#{file_name.gsub("_resource", "")}_policy.rb").to_s
  if File.file? policy_path
    content_to_be_hashed += File.read(policy_path)
  end

  Digest::MD5.hexdigest(content_to_be_hashed)
end
```

It's an md5 of the resource file name, the policy file (so the cache gets busted when the rules change). We also add the `parent_record` when it's displayed in as an association, so there's a separate cache record for each association.

This is the default, but if you have special requirements you can add it to your resource file and it will be used to cache your records accordingly.

```ruby
class Avo::Resources::User < Avo::BaseResource
  def cache_hash(parent_record)
    result = [record, file_hash, "SOMETHING_NEW"]

    if parent_record.present?
      result << parent_record
    end

    result
  end

  # fields, cards and more
end
```
</Option>

<Option name="`self.external_link`">

<VersionReq version="3.15.6" />

<br>
<br>

<Image src="/assets/img/resources/external-link.png" width="1293" height="426" alt="External link demonstration" />

It's often desirable to provide users with a link to the public path of a record outside of the Avo interface. The `external_link` option allows you to achieve this.

### Usage

To define an external link for a resource, set the `self.external_link` option with a lambda function. Within this lambda function, you gain access to all attributes of `Avo::ExecutionContext` along with the `record`.

```ruby{2-4}
class Avo::Resources::Post < Avo::BaseResource
  self.external_link = -> { # [!code focus]
    main_app.post_path(record) # [!code focus]
  } # [!code focus]
end
```

The `self.external_link` lambda should return a string representing the URL of the record.

You can use path helpers from your application (e.g., `main_app.post_path`) or any external URL generator.

When this option is configured, Avo will display an external link button for the resource. Clicking it will take the user to the specified URL.

</Option>

<Option name="`self.discreet_information`">

<VersionReq version="3.17" />

Oftern we want to show some information about records without adding another field. `discreet_information` does exactly that 🙌

More information on `discreet_information`

</Option>

## Cards

Use the `def cards` method to add some cards to your resource.

Check cards documentation for more details.

```ruby{9-19}
class Avo::Resources::User < Avo::BaseResource
  def fields
    field :id, as: :id
    field :name, as: :text
    field :email, as: :text
    field :roles, as: :boolean_group, options: {admin: "Administrator", manager: "Manager", writer: "Writer"}
  end

  def cards
    card Avo::Cards::ExampleAreaChart, cols: 3
    card Avo::Cards::ExampleMetric, cols: 2
    card Avo::Cards::ExampleMetric,
      label: "Active users metric",
      description: "Count of the active users.",
      arguments: { active_users: true },
      visible: -> { !resource.view.form? }
  end
end
```

<Image src="/assets/img/cards_on_resource.png" width="2520" height="1258" alt="Cards on resources - Avo for Rails" />

---