Skip to content

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
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.

2 participants