Skip to content

Comments

Action View Form Helpers Guide#6

Open
bhumi1102 wants to merge 53 commits intomainfrom
bhumi-guides-form-helpers
Open

Action View Form Helpers Guide#6
bhumi1102 wants to merge 53 commits intomainfrom
bhumi-guides-form-helpers

Conversation

@bhumi1102
Copy link
Owner

@bhumi1102 bhumi1102 commented Apr 29, 2024

This one is ready for internal review. It is a bit long but not too bad.

Among other edits and code example updates, I've address the bullet points from the Todo:

  • Do we still need an HTML5 warning at the end of the 1st section? It's pretty standard these days.
    --> agree, removed.
  • Not sure the output of _form_with model: @article_ is 100% correct, might need to double check that.
    --> yes. updated this example and got the HTML output from my "guides playground" rails app.
  • When we mention record.persisted? in record identification, could be a good plug to link to the Active Model guide on that.
    --> Hm...there is no direction mention, other than this https://guides.rubyonrails.org/active_model_basics.html#conversion
  • Similar to STI, link to the guide / reference on it.
  • Time Zone and Country Select should likely be broken into separate sub-sections (I don't mind still mentioning country select)
  • Would the file upload example would be better with a CSV for local processing, rather than showing saving to local disk? (which is probably a very uncommon usage?)
  • The labeled_form_with example could likely be simplified with _**options_ being all that it takes, instead of explicitly showing all possible kwargs.
  • It may be better to show "complex forms" (section 10) right after the parameters (section 8), moving "forms to external resources" down... just because complex forms require exactly the fields_for incantation that was detailed further under the parameters section, so it seems a better continuation. (or potentially even reversed? complex forms then params? not sure)
  • Under "complex forms", adding fields on the flow could be slightly expanded, it feels very "go figure".
    --> Yeah, not sure what to do about this one. Was thinking about removing it as there is not built-in support to showcase.

@bhumi1102 bhumi1102 changed the title Action View Form Helpers (WIP) Action View Form Helpers Guide May 7, 2024
Copy link
Collaborator

@p8 p8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. I'm halfway reviewing and hope to continue on friday.

Copy link
Collaborator

@Ridhwana Ridhwana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking so good @bhumi1102. I've reviewed until line 300, will send the reviews in batches as I work through the whole file.

Copy link
Collaborator

@Ridhwana Ridhwana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review until line 618

--------------------------------------------------------------------------------

NOTE: This guide is not intended to be a complete documentation of available form helpers and their arguments. Please visit [the Rails API documentation](https://api.rubyonrails.org/classes/ActionView/Helpers.html) for a complete reference of all available helpers.
NOTE: This guide is not intended to be a complete list of all available form helpers. Please reference [the Rails API documentation](https://api.rubyonrails.org/classes/ActionView/Helpers.html) for an exhaustive list of form helpers and their arguments.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also maybe replace exhaustive with the simpler complete?

Suggested change
NOTE: This guide is not intended to be a complete list of all available form helpers. Please reference [the Rails API documentation](https://api.rubyonrails.org/classes/ActionView/Helpers.html) for an exhaustive list of form helpers and their arguments.
NOTE: This guide is not intended to be a complete list of all available form helpers. Please reference [the Rails API documentation](https://api.rubyonrails.org/classes/ActionView/Helpers.html) for a complete list of form helpers and their arguments.

bhumi1102 pushed a commit that referenced this pull request Dec 11, 2025
* Active storage immediate variants (#6)

* This commit introduces variant generation strategies for Active Storage,
providing more flexible control over when variants are created.

- **:lazily** - variants created dynamically when requested (default)
- **:later** - variants created in background after attachment
- **:immediately** - variants created simultaneously with attachment

```ruby
has_one_attached :avatar_with_lazy_variants do |attachable|
  attachable.variant :lazy_thumb, resize_to_limit: [3, 3], process: :lazy
  attachable.variant :default_thumb, resize_to_limit: [4, 4]
end

has_one_attached :avatar_with_later_variants do |attachable|
  attachable.variant :later_thumb, resize_to_limit: [2, 2], process: :later
end

has_one_attached :avatar_with_immediate_variants do |attachable|
  attachable.variant :immediate_thumb, resize_to_limit: [1, 1], process: :immediately
end
```

* Active Storage: make Variant#processed? and VariantWithRecord#processed? public

Apps can now check whether variants have been generated. Useful for
precise control of variant usage or generation.

Co-authored-by: Tom Rossi <tomrossi7@users.noreply.github.com>

* Deprecate `preprocessed: true` in favor of `process: :later`

For removal in Rails 9.0.

Co-authored-by: Tom Rossi <tomrossi7@users.noreply.github.com>

* Document immediate variants: guide and changelog

Co-authored-by: Tom Rossi <tomrossi7@users.noreply.github.com>

* Making ActiveStorage::Preview#processed? a public method

Removing space

* Use consistent naming for transformations parameter (#7)

ActiveStorage uses the plural `transformations` for a single hash of transformation options (e.g., `{ resize_to_limit: [100, 100] }`).

To differentiate between a single transformation hash and an array of transformation hashes, this commit introduces `transformations_array` for arrays of transformations, while retaining transformations for individual hashes.

* Fixing changelog

* Rename transformations_array to variants

Aligns with `CreateVariantsJob` naming and `ActiveStorage` terminology
where variants represent the result of transformations applied to
the original blob.

Fixing create_preview_image

---------

Co-authored-by: Jeremy Daer <jeremy@rubyonrails.org>
Co-authored-by: Tom Rossi <tomrossi7@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants