Topic: Best practice/fewest headaches for has_many/belongs_to
I'm writing a basic forum for a small community, and I'm wrestling on what's considered "best practice" in this situation.
Let's say I have topics and threads. (Or blogs and posts, etc.) Threads belong to topics, and they don't make sense outside the context of belonging to a topic. My question is, when displaying multiple "threads" it more correct to:
(1) create a controller method that displays all threads in a specific topic e.g.,
(2) pass the topic ID to a thread method that displays all threads with that passed ID e.g.
I'm trying to create a situation where that context is respected, e.g., threads are always manipulated within the context of their topic, with a few exceptions.
#1 feels hacky, as I end up rendering a lot of partials from the thread views and trying to do much of the thread's work via the topic's controller - there's a lot of back and forth, but it works well. With this one I end up passing the topic ID to the thread controller for things like thread creation, via a hidden form element. #2 seems easier, but I'm not wild about passing the topic ID around.
Any thoughts are appreciated.
Last edited by synthemesc (2006-12-01 14:18:26)