Sha256: ad491abd0dbf176d49b0c80aa69cb0d683a894ce3e10d0e18cd29ac15f94ec45

Contents?: true

Size: 1.2 KB

Versions: 13

Compression:

Stored size: 1.2 KB

Contents

# Examples and setup for the `file_field` Field Partial

## Active Storage

`file_field` is designed to be used with [Active Storage](https://edgeguides.rubyonrails.org/active_storage_overview.html). You will need to confgure Active Storage for your application before using this field partial. You can find instructions for doing so in the [Rails Guides](https://edgeguides.rubyonrails.org/active_storage_overview.html#setup).

In addition, Bullet Train has integrated the direct-uploads feature of Active Storage. For this to work, you need to have CORS configured for your storage endpoint. You can find instructions for doing so in the [Rails Guides](https://edgeguides.rubyonrails.org/active_storage_overview.html#cross-origin-resource-sharing-cors-configuration).

## Example

The following steps illustrate how to add a `document` file attachment to a `Post` model.
Add the following to `app/models/post.rb`:

```ruby
has_one_attached :document
```

Note, no database migration is required as ActiveStorage uses its own tables to store the attachments.

Run the following command to generate the scaffolding for the `document` field on the `Post` model:

```bash
./bin/super-scaffold crud-field Post document:file_field
```

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
bullet_train-1.3.12 docs/field-partials/file-field.md
bullet_train-1.3.11 docs/field-partials/file-field.md
bullet_train-1.3.10 docs/field-partials/file-field.md
bullet_train-1.3.9 docs/field-partials/file-field.md
bullet_train-1.3.8 docs/field-partials/file-field.md
bullet_train-1.3.7 docs/field-partials/file-field.md
bullet_train-1.3.6 docs/field-partials/file-field.md
bullet_train-1.3.5 docs/field-partials/file-field.md
bullet_train-1.3.4 docs/field-partials/file-field.md
bullet_train-1.3.3 docs/field-partials/file-field.md
bullet_train-1.3.2 docs/field-partials/file-field.md
bullet_train-1.3.1 docs/field-partials/file-field.md
bullet_train-1.3.0 docs/field-partials/file-field.md