Conversation
WalkthroughThe PR replaces legacy widget integration with a File Uploader Web Components approach, adds importmap generator and initializer template, updates configuration and view helpers (include tags, uploader tags, form builder), updates generator templates and docs, modernizes gemfiles (adds Rails 8.1), standardizes quoting and RuboCop config, and expands tests. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (2)
🔇 Additional comments (4)
✏️ Tip: You can disable this entire section by setting Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
f293be8 to
de09a0c
Compare
de09a0c to
7209619
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@gemfiles/Gemfile-rails-8-1`:
- Around line 1-14: Add the missing ostruct gem to the test Gemfile by adding
gem "ostruct" (without require) to gemfiles/Gemfile-rails-8-1 so specs that use
OpenStruct (e.g., those under spec/uploadcare/rails/objects/file_spec.rb and
spec/uploadcare/rails/active_record/*) work on Ruby 3.3+ where ostruct is no
longer bundled.
In `@lib/generators/templates/uploadcare_config_template.erb`:
- Around line 24-28: The template enables ActiveJob-related flags by default
(config.store_files_async and config.delete_files_async) but lacks guidance
about ActiveJob backend requirements; either set both flags to false by default
to avoid runtime failures for apps without ActiveJob configured, or add an
explanatory comment above these lines indicating that enabling them requires a
configured ActiveJob adapter and queueing system and that they only take effect
when store_files_after_save and delete_files_after_destroy are true; update the
template to implement one of these two safer options and ensure references to
store_files_after_save and delete_files_after_destroy remain in the comment for
clarity.
🧹 Nitpick comments (15)
.github/workflows/test.yml (1)
34-36: Inconsistent quoting of Ruby version.The
testjob uses quoted strings for Ruby versions ("3.2","3.3","3.4"), butcode-analysisuses an unquoted3.3. For consistency and to prevent potential YAML parsing issues, consider quoting this value as well.Suggested fix
strategy: matrix: ruby-version: - - 3.3 + - "3.3".rubocop.yml (1)
4-5: Address mismatch between gemspec and CI Ruby version requirements.The gemspec declares
gem.required_ruby_version = '>= 2.7.0', but the CI matrix tests only Ruby 3.2, 3.3, and 3.4. Either update the gemspec to require Ruby 3.2+ (and setTargetRubyVersion: 3.2accordingly), or restore Ruby 2.7 testing to the CI matrix to match the declared requirement.lib/generators/uploadcare_importmap_generator.rb (1)
12-19: Heredoc indentation will produce extra whitespace in importmap.rb.The
<<~RUBYsquiggly heredoc removes leading whitespace based on the least-indented line, but the content starts with an empty line and has 8-space indentation. This will append correctly formatted content, but the leading blank line (line 14) may be unintended.♻️ Minor cleanup suggestion
append_to_file importmap_path do <<~RUBY - # Uploadcare File Uploader pin "@uploadcare/file-uploader", to: "https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@v1/web/file-uploader.min.js" pin "uploadcare" RUBY endlib/uploadcare/rails/action_view/uploadcare_form_builder.rb (1)
60-70: Consider extracting shared error-handling logic.The
uploadcare_object_has_errors?anduploadcare_error_wrappingmethods are duplicated between this file andlib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb(lines 157-168). While the slight signature difference (this usesobjectimplicitly vs. explicit parameter) is acceptable, consolidating into a shared module could reduce maintenance burden.This is minor since both implementations are simple and the duplication is intentional for different contexts (FormBuilder vs. view helper).
lib/uploadcare/rails/action_view/uploadcare_include_tags.rb (1)
71-78: Consider extracting shared CSS URL construction.The CSS URL building logic (lines 71-76) duplicates lines 38-43 in
uploadcare_include_tag. A private helper could reduce this duplication.♻️ Suggested extraction
private def uploadcare_css_url(version:, solution:, min:) min_suffix = min ? ".min" : "" base_path = FILE_UPLOADER_PATH.sub("@v1", "@#{version}") css_path = "#{base_path}/uc-file-uploader-#{solution}#{min_suffix}.css" URI::HTTPS.build(host: CDN_HOST, path: css_path).to_s endThen both methods can call
stylesheet_link_tag(uploadcare_css_url(version:, solution:, min:)).lib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb (1)
83-91: Redundant nil check for required keyword argument.On line 84,
ctx_name ||= SecureRandom.uuidis unnecessary becausectx_name:is a required keyword argument (no default value). Callers must provide it or get anArgumentError. This line could be removed for clarity.Suggested fix
def uploadcare_uploader(ctx_name:, solution: "regular", **options) - ctx_name ||= SecureRandom.uuid - config = uploadcare_config_tag(ctx_name: ctx_name, **options) uploader = uploadcare_uploader_tag(ctx_name: ctx_name, solution: solution) ctx_provider = uploadcare_ctx_provider_tag(ctx_name: ctx_name)README.md (3)
168-175: Documentation improvement: Add descriptive text for "here" link.The link on line 170 uses "here" as link text, which is flagged by accessibility linters (MD059). Consider making the link text more descriptive.
-- **solution** — solution type. Available names are "regular", "inline", "minimal". - Default is "regular". More info about solutions [here](https://uploadcare.com/docs/file-uploader/solutions/). +- **solution** — solution type. Available names are "regular", "inline", "minimal". + Default is "regular". See [File Uploader solutions documentation](https://uploadcare.com/docs/file-uploader/solutions/) for more info.
181-183: Consider removing unnecessary dollar sign prefix in command.Line 182 shows a shell command with
$prefix but no output. For commands that don't show output, the dollar sign can be omitted per markdown best practices (MD014).-```console -$ rails g uploadcare_importmap -``` +```console +rails g uploadcare_importmap +```
223-231: Consider using a heading instead of bold text for "Manual Setup" section.Line 223 uses bold emphasis (
**Manual Setup**) as a de facto heading. Using an actual heading improves document structure and accessibility.-**Manual Setup** - -If you prefer manual setup, create your JavaScript initializer in `app/javascript/uploadcare.js`: +##### Manual Setup + +If you prefer manual setup, create your JavaScript initializer in `app/javascript/uploadcare.js`:spec/uploadcare/rails/action_view/uploadcare_form_builder_spec.rb (2)
210-213: MoveRSpec.configurebefore the test blocks.The
RSpec.configureblock at the end of the file includesUploadcareUploaderTagsandFormHelpermodules, but this configuration should be placed before theRSpec.describeblocks to ensure the modules are available when tests run. While RSpec processes configuration blocks first regardless of position, placing it at the beginning improves readability and follows convention.Suggested reorganization
require 'spec_helper' require 'uploadcare/rails/action_view/uploadcare_uploader_tags' require 'uploadcare/rails/action_view/uploadcare_form_builder' +RSpec.configure do |c| + c.include Uploadcare::Rails::ActionView::UploadcareUploaderTags, type: :helper + c.include ActionView::Helpers::FormHelper, type: :helper +end + RSpec.describe 'ActionView::Helpers::FormBuilder#uploadcare_file', type: :helper doAnd remove lines 210-213 from the end of the file.
42-45: Inline rescue catches all exceptions.The
rescue 'object'catches all exceptions, not justNoMethodErrorfor classes without names. This is generally a code smell, but acceptable in test helper code. Consider being more explicit if this pattern is reused elsewhere.More explicit alternative
def form_builder_for(object, object_name: nil) - object_name ||= object.class.name.underscore rescue 'object' + object_name ||= begin + object.class.name.underscore + rescue NoMethodError, NameError + 'object' + end ActionView::Helpers::FormBuilder.new(object_name, object, self, {}) endspec/uploadcare/rails/action_view/uploadcare_include_tags_spec.rb (1)
96-98: MoveRSpec.configurebefore the test blocks for consistency.Same as the form builder spec - while RSpec processes configuration blocks first, placing it before the
describeblocks improves readability.spec/uploadcare/rails/action_view/uploadcare_uploader_tags_spec.rb (2)
96-106: Consider extracting shared mock classes to reduce duplication.The
mock_errors_classdefinition (lines 96-106) is duplicated fromuploadcare_form_builder_spec.rb(lines 12-22). Consider extracting this to a shared support file.Example shared support file
# spec/support/uploadcare_test_helpers.rb module UploadcareTestHelpers def mock_errors_class Class.new do def initialize(errors = {}) `@errors` = errors end def [](key) `@errors`[key] || [] end end end end RSpec.configure do |c| c.include UploadcareTestHelpers, type: :helper end
407-409: Consider movingRSpec.configureto the top of the file.For consistency and readability, consider placing the configuration before the
describeblocks.lib/generators/templates/uploadcare_config_template.erb (1)
132-141: Misplacedmetadataoption under Localization section.The
metadataconfiguration option (lines 140-141) is unrelated to localization and should be moved to a more appropriate section, such as "Output Options" or "File Uploader Configuration".Suggested fix
# ============================================================================= # Localization # ============================================================================= # Available locales: ar, ca, cs, da, de, el, en, es, et, fr, he, hr, hu, id, # it, ja, ko, nb, nl, pl, pt, ro, ru, sk, sr, sv, tr, uk, vi, zh-CN, zh-TW config.locale = 'en' - - # Custom metadata to attach to uploaded files - # config.metadata = {}Move the metadata option to the "Output Options" section:
# ============================================================================= # Output Options # ============================================================================= # Output file group instead of individual files when multiple is enabled # config.group_output = true + + # Custom metadata to attach to uploaded files + # config.metadata = {}
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (50)
.github/workflows/test.yml.rubocop.ymlGemfileREADME.mdgemfiles/Gemfile-rails-7-0gemfiles/Gemfile-rails-7-1gemfiles/Gemfile-rails-7-2gemfiles/Gemfile-rails-8-1lib/generators/templates/uploadcare_config_template.erblib/generators/templates/uploadcare_js_initializer.jslib/generators/uploadcare_config_generator.rblib/generators/uploadcare_importmap_generator.rblib/uploadcare-rails.rblib/uploadcare/rails.rblib/uploadcare/rails/action_view/uploadcare_form_builder.rblib/uploadcare/rails/action_view/uploadcare_include_tags.rblib/uploadcare/rails/action_view/uploadcare_uploader_tags.rblib/uploadcare/rails/active_record/mount_uploadcare_file.rblib/uploadcare/rails/active_record/mount_uploadcare_file_group.rblib/uploadcare/rails/api/rest/addons_api.rblib/uploadcare/rails/api/rest/base.rblib/uploadcare/rails/api/rest/conversion_api.rblib/uploadcare/rails/api/rest/file_api.rblib/uploadcare/rails/api/rest/file_metadata_api.rblib/uploadcare/rails/api/rest/group_api.rblib/uploadcare/rails/api/rest/project_api.rblib/uploadcare/rails/api/rest/webhook_api.rblib/uploadcare/rails/api/upload/base.rblib/uploadcare/rails/api/upload/upload_api.rblib/uploadcare/rails/configuration.rblib/uploadcare/rails/engine.rblib/uploadcare/rails/jobs/delete_file_job.rblib/uploadcare/rails/jobs/store_file_job.rblib/uploadcare/rails/jobs/store_group_job.rblib/uploadcare/rails/mongoid/mount_uploadcare_file.rblib/uploadcare/rails/mongoid/mount_uploadcare_file_group.rblib/uploadcare/rails/objects/concerns/loadable.rblib/uploadcare/rails/objects/file.rblib/uploadcare/rails/objects/group.rblib/uploadcare/rails/services/files_count_extractor.rblib/uploadcare/rails/transformations/image_transformations.rblib/uploadcare/rails/version.rbspec/uploadcare/rails/action_view/uploadcare_form_builder_spec.rbspec/uploadcare/rails/action_view/uploadcare_include_tags_spec.rbspec/uploadcare/rails/action_view/uploadcare_uploader_tags_spec.rbspec/uploadcare/rails/action_view/uploadcare_widget_tags_spec.rbspec/uploadcare/rails/active_record/mount_uploadcare_file_spec.rbspec/uploadcare/rails/api/rest/file_api_spec.rbspec/uploadcare/rails/api/upload/upload_api_spec.rbuploadcare-rails.gemspec
💤 Files with no reviewable changes (1)
- spec/uploadcare/rails/action_view/uploadcare_widget_tags_spec.rb
🧰 Additional context used
🧬 Code graph analysis (8)
spec/uploadcare/rails/api/rest/file_api_spec.rb (1)
lib/uploadcare/rails/api/rest/file_api.rb (2)
store_files(59-61)delete_files(66-68)
spec/uploadcare/rails/action_view/uploadcare_form_builder_spec.rb (2)
spec/uploadcare/rails/action_view/uploadcare_uploader_tags_spec.rb (3)
initialize(90-92)initialize(98-100)key(102-104)lib/uploadcare/rails/configuration.rb (1)
include(8-136)
spec/uploadcare/rails/action_view/uploadcare_uploader_tags_spec.rb (2)
lib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb (7)
uploadcare_uploader_field_tag(64-71)uploadcare_uploader_field(33-47)uploadcare_uploader(83-91)uploadcare_config_tag(99-121)uploadcare_uploader_tag(124-126)uploadcare_ctx_provider_tag(129-131)uploadcare_form_input_tag(148-152)lib/uploadcare/rails/configuration.rb (1)
include(8-136)
spec/uploadcare/rails/action_view/uploadcare_include_tags_spec.rb (1)
lib/uploadcare/rails/action_view/uploadcare_include_tags.rb (2)
uploadcare_include_tag(37-57)uploadcare_stylesheet_tag(71-78)
lib/generators/uploadcare_importmap_generator.rb (1)
lib/generators/uploadcare_config_generator.rb (1)
desc(4-12)
lib/uploadcare/rails/action_view/uploadcare_form_builder.rb (1)
lib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb (3)
uploadcare_uploader_field_tag(64-71)uploadcare_object_has_errors?(158-163)uploadcare_error_wrapping(167-169)
lib/uploadcare/rails/objects/file.rb (1)
lib/uploadcare/rails/transformations/image_transformations.rb (1)
call(16-18)
spec/uploadcare/rails/api/upload/upload_api_spec.rb (1)
lib/uploadcare/rails/api/upload/upload_api.rb (2)
upload(43-45)upload_files(27-31)
🪛 markdownlint-cli2 (0.18.1)
README.md
170-170: Link text should be descriptive
(MD059, descriptive-link-text)
182-182: Dollar signs used before commands without showing output
(MD014, commands-show-output)
223-223: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
🔇 Additional comments (71)
lib/uploadcare/rails/objects/concerns/loadable.rb (2)
3-3: LGTM: Style update aligns with rubocop-rails-omakase.The quote style change is purely cosmetic and consistent with the PR's adoption of rubocop-rails-omakase code style.
15-15: LGTM: Formatting update aligns with rubocop-rails-omakase.The spacing change in the array literal is purely cosmetic and consistent with the PR's adoption of rubocop-rails-omakase code style. The logic remains unchanged.
lib/uploadcare/rails/objects/file.rb (4)
3-5: Style changes align with rubocop-rails-omakase.These double-quote changes are consistent with the stated adoption of rubocop-rails-omakase code style.
14-14: LGTM!Array spacing follows the adopted rubocop-rails-omakase style convention.
18-23: LGTM!The array spacing change is purely cosmetic. The
transform_urllogic correctly joins the CDN URL with the transformations query string using "-", which aligns with howImageTransformations#callformats its output.
39-48: LGTM!The
elseandendkeyword alignment with the assignment start is a valid Ruby style for multi-line conditional assignments. Logic remains unchanged.lib/uploadcare/rails/active_record/mount_uploadcare_file_group.rb (1)
3-7: LGTM!The double-quoted string style for
requirestatements aligns with the rubocop-rails-omakase style guide adoption mentioned in the PR objectives.lib/uploadcare/rails/services/files_count_extractor.rb (1)
8-10: LGTM!Style-only change from single to double quotes. The extraction logic remains correct.
lib/uploadcare/rails/jobs/store_file_job.rb (1)
3-3: LGTM!Style-only change for the
requirestatement.lib/uploadcare/rails/version.rb (1)
5-5: LGTM!Style-only change for the VERSION constant string literal.
lib/uploadcare-rails.rb (1)
3-14: LGTM!All
requirestatements consistently updated to double-quoted strings, aligning with the rubocop-rails-omakase style adoption.lib/uploadcare/rails.rb (1)
3-3: LGTM!Style change aligns with the adopted rubocop-rails-omakase code style.
lib/uploadcare/rails/jobs/delete_file_job.rb (1)
3-3: LGTM!Style change consistent with the rubocop-rails-omakase adoption.
lib/uploadcare/rails/mongoid/mount_uploadcare_file.rb (1)
3-8: LGTM!Require statements updated to double quotes for style consistency. No functional changes.
lib/uploadcare/rails/mongoid/mount_uploadcare_file_group.rb (1)
3-8: LGTM!Require statements updated to double quotes for style consistency. No functional changes.
uploadcare-rails.gemspec (1)
13-15: LGTM!Array formatting updated to include spaces inside brackets, consistent with rubocop-rails-omakase style.
lib/uploadcare/rails/objects/group.rb (1)
3-5: LGTM — Style changes align with rubocop-rails-omakase adoption.The updates to double-quoted strings and spacing adjustments are consistent with the PR's code style migration. No functional changes.
Also applies to: 24-24, 47-49
lib/generators/templates/uploadcare_js_initializer.js (1)
1-25: Good template structure with helpful commented examples.The minimal active code correctly initializes the Web Components. The commented examples for Turbo and Turbolinks event handling provide useful guidance.
One consideration: for Rails apps using Turbo (the default in Rails 7+), users will likely need to uncomment the
turbo:loadlistener (lines 20-22) to ensure the uploader reinitializes on navigation. Consider adding a brief note in the comment indicating this is commonly needed for SPA-style navigation.lib/uploadcare/rails/active_record/mount_uploadcare_file.rb (1)
3-7: LGTM — Style-only changes to require statements.No functional changes. The double-quoted strings align with the codebase's style migration.
lib/uploadcare/rails/api/upload/upload_api.rb (1)
3-3: LGTM — String literal style updates only.No functional changes to the upload API logic.
Also applies to: 30-30
spec/uploadcare/rails/api/upload/upload_api_spec.rb (1)
63-63: LGTM — Formatting adjustment for array spacing.Minor whitespace change consistent with the codebase style migration. Test behavior unchanged.
.github/workflows/test.yml (1)
10-17: LGTM on matrix updates.Adding Rails 8.1 to the test matrix and using quoted string literals for Ruby versions is the correct approach—this prevents YAML from interpreting versions like
3.1as floats.Gemfile (1)
11-19: LGTM!Good addition of
ostructfor Ruby 3.3+ compatibility (whereOpenStructis no longer part of the default gems). The switch torubocop-rails-omakasealigns with the PR's adoption of Rails-standard code style..rubocop.yml (1)
1-3: LGTM on adopting rubocop-rails-omakase.Inheriting from
rubocop-rails-omakaseprovides a well-maintained, Rails-aligned RuboCop configuration, reducing custom rule maintenance.lib/uploadcare/rails/transformations/image_transformations.rb (1)
1-45: LGTM!The changes are purely formatting updates to align with
rubocop-rails-omakasestyle (double-quoted strings, spacing around array literals). The transformation logic remains unchanged and correct.spec/uploadcare/rails/active_record/mount_uploadcare_file_spec.rb (3)
11-12: LGTM on Rails stub setup.The conditional
stub_constfor Rails and the cache mock properly isolate the test from needing a real Rails environment. This prevents errors when the implementation accessesRails.cache.
20-30: Good refactor to mirror ActiveRecord's attributes pattern.The
@attributeshash approach better simulates how ActiveRecord models store attributes, making the test more realistic. The explicitpicture=writer andattributesaccessor provide the necessary interface for the mount behavior.
45-57: Solid test coverage for CDN URL assignment.The test properly validates that:
- The CDN URL is stored in the attributes hash
- A
Uploadcare::Rails::Fileobject is constructed- The
cdn_urlaccessor returns the original URL- The
uuidis correctly extracted from the URL pathlib/generators/uploadcare_importmap_generator.rb (3)
25-27: LGTM on initializer creation.The method correctly uses
copy_fileto create the JS initializer, consistent with the pattern used inUploadcareConfigGenerator.
53-55: LGTM on importmap_path helper.Using
Rails.root.joinreturns aPathname, which supports the.exist?check used inadd_importmap_pins.
43-45: No changes needed. Theuploadcare_config_taghelper is properly defined in the codebase and is correctly used in the post-install message.Likely an incorrect or invalid review comment.
lib/uploadcare/rails/action_view/uploadcare_form_builder.rb (1)
37-55: LGTM on FormBuilder integration.The
uploadcare_filemethod correctly:
- Generates a unique
ctx_namewhen not provided- Constructs the field name using Rails conventions (
object_name[method])- Delegates to the template's helper for HTML generation
- Applies error wrapping when validation errors exist
lib/uploadcare/rails/engine.rb (2)
12-16: LGTM on ActionView helper loading.The load order is correct -
uploadcare_form_builderis loaded afteruploadcare_uploader_tags, ensuring theuploadcare_uploader_field_taghelper is available when the FormBuilder extension is required.
3-30: Quote style updates align with rubocop-rails-omakase.The consistent use of double quotes throughout the file follows the new code style adopted in this PR.
lib/uploadcare/rails/action_view/uploadcare_include_tags.rb (3)
11-12: LGTM on CDN constants.Centralizing the CDN host and path as constants makes the code more maintainable and ensures consistency across helpers.
37-57: LGTM on include tag implementation.The method cleanly handles both CDN and importmap modes:
- Builds URLs using
URI::HTTPS.buildfor safety- Early returns CSS-only for importmap mode
- Uses ES module import pattern for the JS tag
safe_joinproperly combines the tags
84-84: LGTM on module inclusion.The module is correctly included into
ActionView::Baseat load time, making the helpers available in all views.lib/uploadcare/rails/configuration.rb (4)
18-53: Well-structured configuration parameters for the new File Uploader.The
FILE_UPLOADER_PARAMSconstant is comprehensive and covers the documented Uploadcare File Uploader options. The inline documentation referencing the configuration docs is helpful.
66-87: Configuration attribute generation looks correct with one edge case consideration.The
uploader_config_attributesmethod correctly:
- Converts snake_case to kebab-case
- Maps
public_keytopubkeyas required by the File Uploader- Handles nil values by skipping them
One minor consideration:
format_config_valuereturns boolean values as-is (line 117), but when these are interpolated into HTML attributes, they render as"true"or"false"strings. This is the expected behavior foruc-configattributes based on the Uploadcare docs.
101-106: Legacywidgetmethod may raiseNoMethodErrorif a parameter is not set.The method uses
public_send(param)for eachWIDGET_PARAMSentry. If any parameter doesn't have a corresponding accessor (shouldn't happen given line 64), or if a typo exists inWIDGET_PARAMS, this will fail at runtime. However, since line 64 ensures all params have accessors viaattr_accessor, this should be safe.
110-121: Consider consistency betweenformat_config_valueandhandle_param_valuefor Array handling.The new
format_config_valuejoins arrays with commas (line 115), while the legacyhandle_param_valuejoins with spaces (line 129). This is intentional — the File Uploader expects comma-separated values while the legacy widget expected space-separated. The distinction is correct but worth noting for future maintainers.lib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb (3)
165-169: Error wrapping implementation follows Rails conventions correctly.The
uploadcare_error_wrappingmethod properly usesinstance_execwithActionView::Base.field_error_proc, matching how Rails' built-in form helpers wrap fields with validation errors. This ensures consistent behavior with standard Rails form fields.
33-47: Model-bound uploader field correctly implements Rails conventions.The helper properly:
- Retrieves the model from instance variables (line 35)
- Generates field names in Rails nested params format (line 38)
- Applies validation error wrapping when errors exist
This matches how Rails' built-in form helpers like
text_fieldwork.
99-121: Manual HTML attribute construction is correct and handles boolean values properly.The manual attribute generation correctly sidesteps ActionView's special handling of the
multipleattribute, andERB::Util.html_escapeappropriately prevents XSS. Uploadcare'suc-configelement correctly interprets the string"false"as a falsy value, so booleanfalsevalues rendering asattribute="false"works as intended and will properly disable themultipleoption.README.md (1)
252-310: Documentation for Uploader Field and FormBuilder is clear and comprehensive.The documentation effectively explains:
- Basic usage with
uploadcare_uploader_field- Generated Web Components and their purposes
- Available options with examples
- FormBuilder integration with
f.uploadcare_fileThis provides a good developer experience for adopting the new File Uploader.
lib/uploadcare/rails/api/rest/base.rb (1)
1-15: Style-only change aligns with rubocop-rails-omakase adoption.The change from single to double quotes for
require "uploadcare"is consistent with the PR's adoption of rubocop-rails-omakase code style. No functional changes.lib/uploadcare/rails/jobs/store_group_job.rb (1)
1-14: Style-only change, job implementation is straightforward.The quote style change aligns with the PR's rubocop-rails-omakase adoption. The job's
performmethod correctly guards against nilgroup_idbefore making the API call.lib/uploadcare/rails/api/rest/file_metadata_api.rb (1)
3-3: LGTM!Style-only change aligning with the rubocop-rails-omakase convention for double-quoted strings.
spec/uploadcare/rails/api/rest/file_api_spec.rb (1)
59-59: LGTM!Array literal spacing updated to match rubocop-rails-omakase style preferences.
Also applies to: 67-67
lib/uploadcare/rails/api/rest/file_api.rb (1)
3-3: LGTM!Style-only change for double-quoted string consistency across the REST API modules.
lib/uploadcare/rails/api/rest/addons_api.rb (1)
3-3: LGTM!Consistent with the double-quoted string convention adopted across the codebase.
lib/uploadcare/rails/api/rest/group_api.rb (1)
3-3: LGTM!Completes the string literal style standardization across the REST API modules.
lib/uploadcare/rails/api/upload/base.rb (1)
3-3: LGTM!String quote style updated to double quotes, consistent with the rubocop-rails-omakase adoption across the codebase.
lib/uploadcare/rails/api/rest/conversion_api.rb (1)
3-3: LGTM!Require statement updated to double-quoted string, aligning with the codebase-wide style standardization.
lib/generators/uploadcare_config_generator.rb (1)
5-10: LGTM!String literals updated to double quotes throughout the generator. Style is now consistent with rubocop-rails-omakase conventions.
lib/uploadcare/rails/api/rest/project_api.rb (1)
3-3: LGTM!Require statement updated to double-quoted string, consistent with the REST API module standardization.
lib/uploadcare/rails/api/rest/webhook_api.rb (2)
3-3: LGTM!Require statement updated to double-quoted string.
22-22: LGTM!Default parameter value updated to double-quoted string. Functionally equivalent, now consistent with the adopted code style.
spec/uploadcare/rails/action_view/uploadcare_form_builder_spec.rb (1)
47-185: Comprehensive test coverage for FormBuilder integration.The test suite thoroughly covers:
- Component generation for all uploader elements
- Name attribute formatting with bracket notation
- Auto-generated and custom
ctx_namehandling- Multiple solution types (regular, inline, minimal)
- Options forwarding to config
- Error wrapping behavior across various scenarios (no errors, field errors, other field errors, nil object, object without errors method)
spec/uploadcare/rails/action_view/uploadcare_include_tags_spec.rb (1)
7-93: Well-structured tests for include tag helpers.The test suite provides good coverage for both
uploadcare_include_taganduploadcare_stylesheet_tag, including:
- Default CDN URLs with correct paths
- Version parameter propagation
- Solution variants (regular, inline, minimal)
- Minified vs non-minified asset handling
- Importmap mode (CSS-only output)
gemfiles/Gemfile-rails-7-2 (1)
5-14: Gemfile dependencies look appropriate for Rails 7.2.The transition from
rubocoptorubocop-rails-omakasealigns with Rails community conventions. Version constraints are reasonable.gemfiles/Gemfile-rails-7-1 (1)
5-14: Consistent with other Rails Gemfiles.Dependencies and version constraints match the Rails 7.2 Gemfile, ensuring consistent behavior across Rails versions.
spec/uploadcare/rails/action_view/uploadcare_uploader_tags_spec.rb (3)
21-80: Good coverage foruploadcare_uploader_field_tag.Tests appropriately verify that this tag-style helper generates all required components without error wrapping, matching the Rails convention where
*_taghelpers don't interact with model state.
286-360: Excellent coverage for config merging edge cases.These tests thoroughly verify the key normalization logic that converts snake_case to kebab-case and properly merges user options with config defaults. The duplicate attribute checks (e.g.,
expect(tag.scan('img-only=').count).to eq(1)) are particularly valuable for ensuring valid HTML output.
209-240: Good coverage for the headless uploader helper.Tests correctly verify that
uploadcare_uploadergenerates components withoutuc-form-input, which is the expected behavior for custom JavaScript handling scenarios.lib/generators/templates/uploadcare_config_template.erb (3)
4-12: Well-structured API Keys section.Clear separation with environment variable fallbacks and appropriate commenting of the secret key.
39-82: Comprehensive File Uploader configuration section.Good coverage of common options with helpful examples and documentation link. The commented defaults allow users to easily customize while understanding available options.
143-161: Clear Image and CDN configuration sections.Well-organized with appropriate defaults. The
cdn_hostnamebeing set to the standard Uploadcare CDN is a sensible default.gemfiles/Gemfile-rails-7-0 (3)
5-5: Good change from GitHub branch to standard gem source.Using the standard gem source
"~> 7.0.0"instead of tracking the GitHub branch provides better stability for CI testing.
7-14: Well-structured gem declarations with appropriate version constraints.Consistent double-quoted strings and explicit version constraints. The
require: falseonmongoidandrubocop-rails-omakaseis appropriate since they're optional/development dependencies.
11-11: rubocop-rails-omakase configuration is properly set up.The
.rubocop.ymlcorrectly inherits fromrubocop-rails-omakaseviainherit_gem: rubocop-rails-omakase: rubocop.yml, and the plainrubocopgem has been removed from all Gemfiles. The switch aligns with the PR objectives and is complete.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Included the 'ostruct' gem in Gemfiles for Rails versions 7.0, 7.1, 7.2, and 8.1 to ensure consistent availability across test environments.
Migrate to File Uploader v1
This PR replaces the legacy jQuery-based widget with the new File Uploader v1, which is built with Web Components for better framework compatibility and modern browser support.
Summary
f.uploadcare_file)New view helpers
Include tags:
uploadcare_include_tag- includes File Uploader CSS and JS from CDNuploadcare_stylesheet_tag- includes only CSS (for importmap/npm setups)Uploader fields:
uploadcare_uploader_field :model, :attribute- model-bound uploader with validation error wrappinguploadcare_uploader_field_tag :name- standalone uploader fielduploadcare_uploader(ctx_name:)- just the uploader component (for custom JS handling)FormBuilder:
f.uploadcare_file :attribute- use withinform_with/form_forblocksGenerated HTML
The helpers generate all required Web Components automatically:
<%= uploadcare_uploader_field :post, :picture %>Results in:
The
<uc-form-input>component handles form synchronization automatically - no manual JavaScript required.New generator
Sets up File Uploader for Rails 7+ applications using importmaps.
Breaking changes
live,manual_start, etc.) are replaced with File Uploader optionsSummary by CodeRabbit
New Features
Documentation
Chores
Tests
✏️ Tip: You can customize this high-level summary in your review settings.