rails/rails — pull request #18022 by agrobbin (2014-12-13 20:53:50+00:00)
Title: Allow URL helpers to work with optional scopes

I believe 84bf3a08150e9e10a29282a7a671a052f00bcd31 introduced a subtle bug with the way you can use URL helpers. As an example, if these are the routes:

```ruby
scope "(/:product)" do
resources :users
end
```

I am no longer able to call the URL helper with `product: nil`:

```ruby
user_path(1, product: nil)
```

Within `handle_positional_args`, we do this:

```ruby
result[param] = inner_options[param] || args.shift
```

`inner_options[param]` will return `nil` in this case, which will fall back to `args.shift`. Changing to `fetch` with a block that gets called as a fallback should correct this behavior.

This should be included in `4-2-stable` as well, but I'll wait to issue a backport PR until this is accepted!