Cool -- these links look great.
I also found a document from March 2007 called RESTful RAILS Development by Wirdemann and Baustert:
http://www.b-simple.de/documents
It agrees with your recommendation above to use a nested route. This makes a lot of sense -- a Topic has many discussions. When a user views or manipulates a discussion, it should be in the context of a topic. One thing I hadn't realized, however, is that my generated controller won't know that it is responsible for a nested resource. Thus, the index action of my DiscussionsController would have to be changed to look like this:
Code:
def index
topic = Topic.find(params[:topic_id])
@discussions = topic.discussions.find(:all)
…
end
(ReggieB in this forum recommended I follow this strategy a few days ago, but I didn't understand it the first time; now I think I do).
One syntax question: why not make topic an instance variable? (as in topic = Topic.find(params[:topic_id])
Is it simply considered a local variable?
Bookmarks