Partial form with nested routes

Posted by jerhinesmith on Stack Overflow See other posts from Stack Overflow or by jerhinesmith
Published on 2010-03-11T03:14:09Z Indexed on 2010/03/14 18:25 UTC
Read the original article Hit count: 280

Filed under:
|

I have two models -- User and Entry -- that are related through a has_many relationship (a User has many Entries). I'm using RESTful routing, and have the following in my routes.rb file:

map.resource :user, :controller => "users" do |user|
  user.resources :entries
end

This seems to work, but in my partial _form file, when I do this:

form_for [@current_user, @entry] do |f|
  # Form stuff
end

It generates a URL like this:

/user/entries.%23%3Cuser:0xb6a6aea8%3E

instead of

/user/entries

Am I missing something?

I should note that the correct classes are applied to the form when doing creation vs. editing, so it does seem to be correctly interpreting what I'm trying to do -- it's just that I can't submit the form to an invalid url.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about routing