rails/rails — Issue #3935: 'form_for' seems lost 'scope' message.
Author: jimrok
Created: 2011-12-11 08:31:49+00:00
State: open

In my rails(3.1.3),

I have defined a Group model using:
```
$ rails g scaffold group name:string
```

Then I add the following in routes.rb

```ruby
scope ":network",:constraints => {:network => /[^\/]+/} do
resources :users
resources :groups
end
```
Next, I access the webpage with the url 'http://localhost:3000/abc.com.cn/groups/1/edit', the form's action url as following seams not right.

<form accept-charset="UTF-8" action="/1/groups/1" class="es-form-group" id="edit_group_1" method="post">
.....

### but, what I expect is /abc.com.cn/groups/1,as the following
<form accept-charset="UTF-8" action="/abc.com.cn/groups/1" class="es-form-group" id="edit_group_1" method="post">
.....

rails seams lost the scope information in params[:network].
I checked the source code of route_set.rb

```ruby
def define_hash_access(route, name, kind, options)
selector = hash_access_name(name, kind)

# We use module_eval to avoid leaks
@module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1
remove_possible_method :#{selector}
def #{selector}(*args)
options = args.extract_options!
result = #{options.inspect}
if args.any?
result[:_positional_args] = args
result[:_positional_keys] = #{route.segment_keys.inspect}
end
result.merge(options)
end
protected :#{selector}
END_EVAL
helpers << selector
end
```

In my case ,The result[:_positional_keys] seems not match the result[:_positional_args] in array size.
The result[:_positional_keys] has three entries,but result[:_positional_args] only has one,the debug message as the following:

```ruby
:_positional_args=>[#], :_positional_keys=>[:network, :id, :format]
```
I think this maybe a bug for rails 's route, someone can give me an advice?

PS: I'm a ruby/rails beginner…I still not understand how the rails'route works, hope the information will be helpful.