DEV Community

shaan-erickson
shaan-erickson

Posted on • Edited on

Questions on W2 homework

Q: What does adding index: true do in a migration file? It allows the database to be sorted/filtered for that column, but couldn't we do that anyway? For example, we added that to the photos migration this week to allow us to look up photos by their owner_id, but couldn't we do that anyway with a .Where?

Q: When we link to the "posts" page (or any other), we include @user.username in the arguments to the path (e.g. <%= link_to "Posts", user_path(@user.username), class: ... %>). When I first implemented, I didn't pass any arguments to user_path and it seemed to work ok. What are the issues/risks of doing so?

Top comments (0)