Call nested _path helper without any arguments

Hello,

I am developing a project using rails 4.0.0 and I came up to a question about nested _path helper.

In my routes I have something like this:

namespace :admins do

resources :educators, shallow: true do

resources :users

end

end

The url to show up the view to create a new user for an educator (e.g. 17) is “/admin/educators/17/users”.

This will show up the following view:

<%= form_for @user_invite, url: admin_educator_users_path do |f| %>

<%= f.text_field :email %>

<%= f.text_area :message %>

<%= f.submit “Invite” %>

<% end %>

Nothing special and works as expected. The @user_invite is an ActiveModel instance a can be ignored for my question. My question refers to the call of the _path helper “admin_educator_users_path” without any arguments. Almost all documentation and the rails guides always call the _path helper like:

admin_educator_users_path(@educator)

It seems like the _path helper is clever enough to extract the missing “educator_id” from the url/params hash.

In the view both invocations:

admin_educator_users_path(@educator)

admin_educator_users_path()

output this:

/admin/educators/17/users

I can even call:

new_admin_educator_user_path()

and the outputs is as expected:

/admin/educators/17/users/new

Is this a feature or an unexpected behavior - I am asking because it is not explicitly mentioned in the rails guides (at least I did not found it).

Any help would be really appreciated.

Regards,

Jan