Skip to content

Commit

Permalink
cache_associations_pagination (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob authored Dec 16, 2024
1 parent 31616b7 commit c8199fd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
34 changes: 34 additions & 0 deletions docs/3.0/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,3 +591,37 @@ Using [searchable](./associations/belongs_to.html#searchable) is recommended for

<Image src="/assets/img/customization/associations-lookup-list-limit.png" width="2466" height="1098" alt="Associations lookup list limit configuration" />
</Option>

<Option name="`cache_associations_pagination`">

<VersionReq version="3.15.4" />

Enables persistent pagination settings for associations across requests.

### Default value

`false`

### How to enable

```ruby{2}
Avo.configure do |config|
config.cache_associations_pagination = true
end
```

When `true`, the `page` and `per_page` settings for each association are stored in the session.

:::warning
**Important**: To avoid potential issues, it is recommended to configure the session store appropriately. Using the cookie store may cause an `ActionDispatch::Cookies::CookieOverflow` error.
:::

### Why change the session store?

The **cookie store** has a 4096-byte size limit, and storing pagination data (page number and records per page) for multiple associations can lead to exceeding this limit, triggering the `ActionDispatch::Cookies::CookieOverflow` error.

By default, Rails uses the cookie store for sessions. To prevent this, switch to a more scalable session store.

For details, see [Rails session store configuration](https://guides.rubyonrails.org/v8.0/configuring.html#config-session-store).

</Option>
8 changes: 8 additions & 0 deletions docs/3.0/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
We'll update this page when we release new Avo 3 versions.

If you're looking for the Avo 2 to Avo 3 upgrade guide, please visit [the dedicated page](./avo-2-avo-3-upgrade).
## Upgrade from 3.15.3 to 3.15.4

A new configuration flag, `cache_associations_pagination`, has been introduced to address frequent cookie overflow issues caused by storing `page` and `per_page` settings for associations in the session. This feature is now disabled by default. If your application requires persistent pagination for associations, you can enable the flag in your configuration.

:::warning
When enabling this feature, it is strongly recommended to change the session store to avoid potential cookie overflow errors. For more details, refer to the [`cache_associations_pagination` configuration documentation](./customization.html#cache_associations_pagination).
:::

## Upgrade from 3.14.0 to 3.14.1

We’ve introduced the [`associations_lookup_list_limit`](customization.html#associations_lookup_list_limit) configuration option to prevent crashing when listing associations on large collections. The new default limit is set to a `1000` records.
Expand Down

0 comments on commit c8199fd

Please sign in to comment.