has_one nested_resource route fails to generate proper url in form_for #4978

aviflombaum opened this Issue Feb 9, 2012 · 5 comments

5 participants


In routes:

resources :users do
  resource :listing

The <%= form_for @user, @listing %> will fail with undefined method user_listings_path

Mentioned over here too http://geekninja.blogspot.com/2008/08/mapresources-hasone-formfor-surprise.html (pre rails 3? really?)

Will look into patching now.

Ruby on Rails member

I don't think it has ever worked to generated the proper url when using resource, in such cases you're supposed to give the url. url_for cannot reflect on routes to see if that's a resource or not.


I was thinking of patching it so that if the app does not respond_to user_listings_path (or whatever url polymorphic_url tries generating) fails, it will then try the singular version.

Ruby on Rails member

I think that @pixeltrix is working on this issue.

Ruby on Rails member

Yep, this is a duplicate of #1769 - closing in favour of that issue.

@pixeltrix pixeltrix closed this May 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment