Nested Routes and Forms in Rails 2.0

If you’re doing a form post to a nested resource, like creating a comment under
/posts/1/comments/
with a route like
map.resources :posts do |post|
post.resources :comments
end

you have to account for that when you’re creating a form, you can’t just send it to the comment and hope everything will work out.

It took me a little time to find this, so I’m posting it in hopes of making someone else’s day easier. What I had to do was
form_for([@post,@comment])
and now everything is happy again.

Ruby on Rails

Comments (2)

Permalink

iPod Touch 1.1.3 + New Apps Upgrade

Support

Comments (0)

Permalink

Happy Holidays

Life In General

Comments (0)

Permalink

Destroying An Object After Touching Its Relatives

Ruby on Rails
Programming

Comments (0)

Permalink

Oh, Seattle Airport!

Life In General

Comments (0)

Permalink

Simplification

Life In General

Comments (0)

Permalink

A Broken Phone, A Loaner Phone

Life In General

Comments (0)

Permalink

My Accent

Life In General

Comments (1)

Permalink

Managing Activity Ideas with Google Calendar

Ideas

Comments (0)

Permalink

Backpacking in the Porkies

Life In General

Comments (0)

Permalink