Nested Model/Routes in Rails 3
Posted
by
mbreedlove
on Stack Overflow
See other posts from Stack Overflow
or by mbreedlove
Published on 2011-02-28T23:23:07Z
Indexed on
2011/02/28
23:24 UTC
Read the original article
Hit count: 159
ruby-on-rails
I have a simple blogging functionality in my Rails 3 app. I am trying to add commenting to each post. The BlogComment
model has a property, blog_post_id
, to be able to find the corresponding comments for each post. I already setup my associations in the model, I also nested BlogComments
under BlogPost
in the routes file.
However, I can't figure out how to give each BlogPost
access to its respective comments through the controller so that they can be shown later in the view.
© Stack Overflow or respective owner