the sugar exists for passing it, but not for receiving it, and to get around this, rails uses splat (varargs) and extract_options! to get the last positional parameter behavior for vararg methods.
vanilla ruby:
def find_by_name(name, options = {})
...
end
rails:
def find_by_name(*args)
opts = args.extract_options!
name = args.shift
...
end
(note, this is not how the dynamic finders actually work, i just wanted to illustrate the difference in the calling and definition.)
So, ruby doesn't include support for varargs with last positional parameter for options, rails builds that in. The fact that it is variable arity is very important -- in fact, that is the root of the present issue. The patches now check the number of arguments.
vanilla ruby:
rails: (note, this is not how the dynamic finders actually work, i just wanted to illustrate the difference in the calling and definition.)So, ruby doesn't include support for varargs with last positional parameter for options, rails builds that in. The fact that it is variable arity is very important -- in fact, that is the root of the present issue. The patches now check the number of arguments.