Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle all false args in config.x error check #50569

Merged
merged 1 commit into from
Jan 3, 2024

Conversation

jonathanhefner
Copy link
Member

Follow-up to #50050.

Using args.none? does not catch the case when all args are false or nil. Therefore, this commit changes the condition to args.empty?.

This commit also changes the error message to more closely match Ruby's error messages when trying to pass an arg to a getter method:

Rails.configuration.x(false)
# => wrong number of arguments (given 1, expected 0) (ArgumentError)

Rails.configuration.x.i_do_not_exist(false)
# => wrong number of arguments (given 1, expected 0) when reading configuration `i_do_not_exist` (ArgumentError)

Follow-up to rails#50050.

Using `args.none?` does not catch the case when all args are `false` or
`nil`.  Therefore, this commit changes the condition to `args.empty?`.

This commit also changes the error message to more closely match Ruby's
error messages when trying to pass an arg to a getter method:

  ```ruby
  Rails.configuration.x(false)
  # => wrong number of arguments (given 1, expected 0) (ArgumentError)

  Rails.configuration.x.i_do_not_exist(false)
  # => wrong number of arguments (given 1, expected 0) when reading configuration `i_do_not_exist` (ArgumentError)
  ```
@rails-bot rails-bot bot added the railties label Jan 3, 2024
@jonathanhefner jonathanhefner merged commit c2e2a1d into rails:main Jan 3, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants