Sha256: d448ea21fc78d1be332c217c21776b73f4bc53fa9ae0a595ee1d48e7552aa8bc

Contents?: true

Size: 1.59 KB

Versions: 17

Compression:

Stored size: 1.59 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.

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

```bash
rails generate super_scaffold:field Post document:file_field
```

## Multiple Attachment Example

The following steps illustrate how to add multiple `document` file attachments to a `Post` model.

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

```bash
rails generate super_scaffold:field Post documents:file_field{multiple}
```

## Generating a Model & Super Scaffold Example

If you're starting fresh, and don't have an existing model you can do something like this:

```
rails generate super_scaffold Project Team name:text_field specification:file_field documents:file_field{multiple}
```

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
bullet_train-1.15.0 docs/field-partials/file-field.md
bullet_train-1.14.2 docs/field-partials/file-field.md
bullet_train-1.14.1 docs/field-partials/file-field.md
bullet_train-1.14.0 docs/field-partials/file-field.md
bullet_train-1.13.0 docs/field-partials/file-field.md
bullet_train-1.12.3 docs/field-partials/file-field.md
bullet_train-1.12.2 docs/field-partials/file-field.md
bullet_train-1.12.1 docs/field-partials/file-field.md
bullet_train-1.12.0 docs/field-partials/file-field.md
bullet_train-1.11.0 docs/field-partials/file-field.md
bullet_train-1.10.0 docs/field-partials/file-field.md
bullet_train-1.9.0 docs/field-partials/file-field.md
bullet_train-1.8.5 docs/field-partials/file-field.md
bullet_train-1.8.4 docs/field-partials/file-field.md
bullet_train-1.8.3 docs/field-partials/file-field.md
bullet_train-1.8.2 docs/field-partials/file-field.md
bullet_train-1.8.1 docs/field-partials/file-field.md