Closed kingcons closed 9 years ago
Why should we avoid deep nesting beyond the increasing number of parameters passed, and the shortness of helpers/routes. These are obviously beneficial to the people writing code, but is there anything beyond the ease of use?
@beguira86 imagine a route that looked like this: GET users/1/posts/2/comments
. Imagine associations like this: A user has_many posts
, a post has many comments
. Based on your route you're saying that you need info to find the user @user = User.find(1)
then data to go find the post @post = Post.find(2)
and then find the comments for that post @comments = @post.comments
. See how we didn't need the user to find the comments? So why are we even including the user in the route? Theres no need for it. If you really need to find the User for that route: @user = post.user
Description
Read up on URL generation, resourceful routing, and form helpers as described here.
Submission
Post a question you have from the reading in the comments when you close this issue for discussion in homework review tomorrow.