Skip to content

Conversation

@walterdavis
Copy link
Contributor

The file input appears to be treated like any of the other input types in Bootstrap 5. This branch simply removes the previous behavior of forcing it to be wrapped in input_with_error, which does not allow options, and instead uses prepend_and_append_input, which does. This is the same pattern used in the text input, for example. Errors are handled inside of the prepend_and_append_input method, so there's no loss of proper feedback after an invalid submit.

@walterdavis
Copy link
Contributor Author

@lcreid Please let me know if you would like any additional tests, or for me to squash the commits etc.

Copy link
Contributor

@lcreid lcreid left a comment

Choose a reason for hiding this comment

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

Looks great. Thank you. One comment that you can respond to according to your judgement, and then we'll merge.

Comment on lines +37 to +41
"#{method_name}#{names}#{'[]' if multiple}"
elsif index
"#{object_name}[#{index}][#{method_name}]#{names}#{multiple ? '[]' : ''}"
"#{object_name}[#{index}][#{method_name}]#{names}#{'[]' if multiple}"
else
"#{object_name}[#{method_name}]#{names}#{multiple ? '[]' : ''}"
"#{object_name}[#{method_name}]#{names}#{'[]' if multiple}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering if these were RuboCop changes, and then I saw your other e-mail. If there are extensive RuboCop changes, I suggest a separate PR, but since the scope is limited, it's fine to be here.

More context: We could freeze RuboCop to certain rules, etc., but honestly I don't have time to do a proper job of maintaining this gem, let alone adding additional tasks around RuboCop, so we just fix style things as they come up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You might think about turning off the auto-correct, then. That would show the findings, and make it more deliberate to fix them in a given patch.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good suggestion. I'll look into that. I'm not even sure why auto-correct is the default, now that you mention it.

Comment on lines +237 to +240
assert_equivalent_html after_button, @builder.file_field(:avatar, append: button_src)
assert_equivalent_html before_button, @builder.file_field(:avatar, prepend: button_src)
assert_equivalent_html both_button, @builder.file_field(:avatar, append: button_src, prepend: button_src)
assert_equivalent_html multiple_button, @builder.file_field(:avatar, append: [button_src] * 2, prepend: [button_src] * 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice set of tests!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shamelessly duped from a few lines up in the same file! 😁

gem "rails", BootstrapForm::REQUIRED_RAILS_VERSION
gem "sprockets-rails", require: "sprockets/railtie"
gem "sqlite3", "~> 1.4"
gem "sqlite3", ">= 1.4"
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you find you needed to change this? There was some dependency issue for Rails 7.1 and earlier where we have to keep SQLite back at 1.4, but if it caused you problems, leave it in. If it didn't actually break anything, let's leave it the way it was, and we'll take it out when we drop support for Rails 7.1.

Copy link
Contributor Author

@walterdavis walterdavis Jun 7, 2025

Choose a reason for hiding this comment

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

I did, but possibly just because I am unsure how to route around this problem in my local environment. I kept getting the "you have already activated sqlite [much higher version]" when I ran the tests, both with and without bundle exec. I can take it back out and just not run the tests here... (edit: To be clear, the tests just would not run at all if I left the gemfile alone.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have both 7.1.x and 8.0.x (rails) installed locally, under ruby 3.2.8.

waltd@Max bootstrap_form % gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.6.9
  - RUBY VERSION: 3.2.8 (2025-03-26 patchlevel 263) [arm64-darwin24]
  - INSTALLATION DIRECTORY: /Users/waltd/.rvm/gems/ruby-3.2.8
  - USER INSTALLATION DIRECTORY: /Users/waltd/.gem/ruby/3.2.0
  - CREDENTIALS FILE: /Users/waltd/.gem/credentials
  - RUBY EXECUTABLE: /Users/waltd/.rvm/rubies/ruby-3.2.8/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /Users/waltd/.rvm/gems/ruby-3.2.8/bin
  - SPEC CACHE DIRECTORY: /Users/waltd/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/waltd/.rvm/rubies/ruby-3.2.8/etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - arm64-darwin-24
  - GEM PATHS:
     - /Users/waltd/.rvm/gems/ruby-3.2.8
     - /Users/waltd/.rvm/rubies/ruby-3.2.8/lib/ruby/gems/3.2.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-document"
     - :benchmark => false
     - :sources => ["http://rubygems.org/"]
  - REMOTE SOURCES:
     - http://rubygems.org/
  - SHELL PATH:
     - /Users/waltd/.rvm/gems/ruby-3.2.8/bin
     - /Users/waltd/.rvm/gems/ruby-3.2.8@global/bin
     - /Users/waltd/.rvm/rubies/ruby-3.2.8/bin
     - /Users/waltd/.pyenv/shims
     - /Users/waltd/.pyenv/bin
     - /opt/homebrew/opt/postgresql@12/bin
     - /Users/waltd/.yarn/bin
     - /Users/waltd/.config/yarn/global/node_modules/.bin
     - /Users/waltd/.nvm/versions/node/v22.1.0/bin
     - /opt/homebrew/bin
     - /opt/homebrew/sbin
     - /usr/local/bin
     - /System/Cryptexes/App/usr/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin
     - /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin
     - /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
     - /Library/Apple/usr/bin
     - /Users/waltd/.rvm/bin

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the reminder. That was it. Something else already activated a later version. But for some reason we wanted to keep earlier versions of Rails on 1.4. Let's go with what you have and then I'll fix this when we drop Rails 7.1.

Copy link
Contributor

@lcreid lcreid left a comment

Choose a reason for hiding this comment

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

Thanks again for this. I can't promise I'll do a release soon, but you can set your Gemfile to pull from main. The code doesn't change that much, so it should be low-risk.

Comment on lines +37 to +41
"#{method_name}#{names}#{'[]' if multiple}"
elsif index
"#{object_name}[#{index}][#{method_name}]#{names}#{multiple ? '[]' : ''}"
"#{object_name}[#{index}][#{method_name}]#{names}#{'[]' if multiple}"
else
"#{object_name}[#{method_name}]#{names}#{multiple ? '[]' : ''}"
"#{object_name}[#{method_name}]#{names}#{'[]' if multiple}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Good suggestion. I'll look into that. I'm not even sure why auto-correct is the default, now that you mention it.

@lcreid lcreid merged commit ef4bfd2 into bootstrap-ruby:main Jun 7, 2025
18 checks passed
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.

2 participants