TIY-ATL-ROR-2015-Sep / assignments

0 stars 0 forks source link

HW 11-09 #412

Closed kingcons closed 9 years ago

kingcons commented 9 years ago

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.

beguira86 commented 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?

sunrick commented 9 years ago

@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