rails/rails — Issue #4260: recognize_path skips scoped params in constraints
Author: ybart
Created: 2012-01-02 14:14:19+00:00
State: open

Using Rails 3.1 and 3.2.0.rc1, using recognize_path causes params not being provided to route constraints.

While the route works correctly when called directly (using a browser, or via `app.get`), it fails being recognized using `recognized_path`.

Here is the route:

```ruby
scope '/prefix/:scoped_param/suffix' do
constraints(ParamConstraint.new) do
resource :success
end
end
```

I can provide a test project if needed.

Here is the constraint

```ruby
class ParamConstraint
def matches?(request)
Rails.logger.info request.params
return request.params[:scoped_param]
end
end
```

Here are the tests

```ruby
class ScopedParamConstraintTest < ActionDispatch::IntegrationTest
test "Can fetch scoped page" do
get helper.success_path(scoped_param: 'test')
assert_response :success
end

test "Can recognize scoped page path" do
assert_not_nil Rails.application.routes.recognize_path(helper.success_path(scoped_param: 'test'))
end
end
```