Man, I have been trying to figure this one out for hours, hopefully
you guys can clue me in.
Let's so you have three "nested" models, for example: Category -> Post
-> Comment (that is, many comments belong to one post and many posts
belong to one category).
So, in your routing configuration you have:
map.resources :categories do |cat|
cat.resources :posts, :has_many => :comments
end
The part I cant figure out, is how to write a "form_for" helper so
that the HTML action="" attribute will end up being "categories/1/
posts/1/comments". The farthest I can seem to get is "posts/1/
comments", which, I could proly skate by with, but I'd really like to
get the entire nested route in their. (I've seen that the rails app
"Basecamp" is able to accomplish this, so it has to be possible).
These are a couple of the things I've tried, both result in an error:
- form_for([:category, @post, Comment.new]) do |f|
- form_for @post, :url => new_category_post_comment_path do |f|
What am I doing wrong here!? Thanks guys.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.