# polymorphic\_url

**URL:** <https://discuss.rubyonrails.org/t/polymorphic-url/60505>\
**Category:** rubyonrails-talk\
**Created:** [August 20, 2011, 9:20pm UTC](https://discuss.rubyonrails.org/t/polymorphic-url/60505 "2011-08-20T21:20:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajaxy](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Ajaxy](https://discuss.rubyonrails.org/u/Ajaxy)\
**Post date:** [August 20, 2011, 9:20pm UTC](https://discuss.rubyonrails.org/t/polymorphic-url/60505/1 "2011-08-20T21:20:22Z")

</div>

Hello all.

Looked through "polymorphic\_url" method (used by "form\_for", "redirect\_to" and other helpers) and observed that is no way to use it with any of non-resource parameters. I.e if we got

resources :users, :scope =\> "/:somestring"

in our routes.rb config, that generates user\_path(@user, { :somestring =\> "brazil" }) linked to [http://site.com/brazil/users/1](http://site.com/brazil/users/1) it fails i.e. "form\_for @user" and "redirect\_to @user", cause it calls method user\_path(@user) without :somestring

and if we write "form\_for [{ :somestring =\> "brazil" }, @user]" it fails on "build\_named\_route\_call" method, which trying to convert first Hash to string-part of named route method name.

Of course we have :url option fo "form\_for", and we can use user\_path right in "redirect\_to" but it seems ugly, and there is no good way always to edit many lines of scaffolded code.

Any suggestions?
