Sha256: dea6e87be0bb751dab8a824b7e6efb4f2051bbaa0beb7b03ea7c3ad8d91b43f6

Contents?: true

Size: 1.17 KB

Versions: 28

Compression:

Stored size: 1.17 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

Add a 'document' file as an 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

28 entries across 28 versions & 1 rubygems

Version Path
bullet_train-1.2.27 docs/field-partials/file-field.md
bullet_train-1.2.26 docs/field-partials/file-field.md
bullet_train-1.2.25 docs/field-partials/file-field.md
bullet_train-1.2.24 docs/field-partials/file-field.md
bullet_train-1.2.23 docs/field-partials/file-field.md
bullet_train-1.2.22 docs/field-partials/file-field.md
bullet_train-1.2.21 docs/field-partials/file-field.md
bullet_train-1.2.20 docs/field-partials/file-field.md
bullet_train-1.2.19 docs/field-partials/file-field.md
bullet_train-1.2.18 docs/field-partials/file-field.md
bullet_train-1.2.17 docs/field-partials/file-field.md
bullet_train-1.2.16 docs/field-partials/file-field.md
bullet_train-1.2.15 docs/field-partials/file-field.md
bullet_train-1.2.14 docs/field-partials/file-field.md
bullet_train-1.2.13 docs/field-partials/file-field.md
bullet_train-1.2.12 docs/field-partials/file-field.md
bullet_train-1.2.11 docs/field-partials/file-field.md
bullet_train-1.2.10 docs/field-partials/file-field.md
bullet_train-1.2.9 docs/field-partials/file-field.md
bullet_train-1.2.8 docs/field-partials/file-field.md