Skip to content

Commit

Permalink
Improve model fields reference doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ellmetha committed Sep 18, 2024
1 parent 5492a7a commit 2c60c72
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/docs/models-and-databases/reference/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ The `serializable` arguments allows to specify that a class making use of [`JSON

A `slug` field allows to persist _valid_ slug values (ie. strings that can only include characters, numbers, dashes, and underscores). In addition to the [common field options](#common-field-options), such fields support the following arguments:

:::info
Since slug fields are usually used to query records, they are indexed by default. You can use the [`index`](#index) option (`index: false`) to disable auto-indexing.
:::

#### `max_size`

The `max_size` argument is optional and defaults to 50 characters. It allows to specify the maximum size of the persisted email addresses. This maximum size is used for the corresponding column definition and when it comes to validate field values.
Expand All @@ -259,7 +263,7 @@ article = Article.create!(title: "My Article")
article.slug # => "my-article"
```

When an Article object is saved, the slug field will automatically generate a slug based on the title field if no custom slug is provided.
When an `Article` object is saved, the slug field will automatically generate a slug based on the title field if no custom slug is provided.

:::warning
The slugification functionality also transforms Unicode characters and symbols. When filtering a model by the query parameter, it may be necessary to decode the slug parameter first, because although the browser may show you the unicode characters, it will send the encoded characters in the HTTP request:
Expand All @@ -275,10 +279,6 @@ end
```
:::

:::info
As slug fields are usually used to query records, they are indexed by default. You can use the [`index`](#index) option (`index: false`) to disable auto-indexing.
:::

### `string`

A `string` field allows to persist small or medium string values. In addition to the [common field options](#common-field-options), such fields support the following arguments:
Expand Down

0 comments on commit 2c60c72

Please sign in to comment.