In my Rails application I have a Forum with many Topics. From the Forum's, "show" page I have a list of Topics with a link to create a new Topic. My goal is to make sure that when creating the new Topic I have the ID of the Forum when I get to the Top开发者_如何转开发ic's "create" method. Right now I'm thinking I'd have to create a hidden field on the Topic's "new" page and set the hidden field to the Forum's ID. I was wondering if there is a better, cleaner way.
Thank you for looking!
Nested resources are the way to go for this, so you nest the Topic
resource within the Forum
resource. Take a look at these tutorials:
- Nested Resources Rails Guide
- Nested Resources Railscast
精彩评论