Earth - Emily - #33
Conversation
… code by adding self to methods. calling those methods in works controller.
…. learned about form-control but i don't like it
…mpts user to login successfully
…r to see if it'll work
Media RankerGreat work! The homepage seems to have multiple errors, due to something you changed in your very last commit trying to fix heroku things. It's always worth checking everything one last time before you submit :) Regardless, you made a whole site with so much interactive functionality that supports signin from many users! This is a big deal! I hope you've been able to celebrate this! Especially in a week when you were also moving! Functional Requirements: Manual Testing
Major Learning Goals/Code Review
Previous Rails learning, Building Complex Model Logic, DRYing up Rails Code
Testing Rails Apps
Overall Feedback
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
|
| redirect_to work_path(@work.id) | ||
| return | ||
| else | ||
| flash.now[:error] = "Oops! Media already exists." |
There was a problem hiding this comment.
I love the idea of having more specific messages for specific situations, but surfacing validation messages is a more fool-proof way to do that.
The way this is currently written, it assumes that if something goes wrong, it's because the work already exists when there are other things that can go wrong.
There was a problem hiding this comment.
In fact, when I try to add a duplicate work, I get the following validation message anyway
title has already been taken
| <h4>Albums</h4> | ||
| <tr> | ||
| <th>Votes</th> | ||
| <th>Title</th> | ||
| <th>Created By</th> | ||
| <th>Published</th> | ||
| <th>Upvote</th> | ||
| </tr> | ||
| <% Work.sort_media('album').each do |album| %> | ||
| <tr> | ||
| <td><%= album.votes.count %></td> | ||
| <td><%= link_to album.title, work_path(album.id) %></td> | ||
| <td><%= album.creator %></td> | ||
| <td><%= album.publication_year %></td> | ||
| <td><%= link_to "Upvote", work_upvote_path(album.id), method: :post, class:"btn btn-primary" %></td> | ||
| <% end %> | ||
| </tr> | ||
| </table> | ||
| </div> |
There was a problem hiding this comment.
This code is repeated for each type of work three times almost exactly the same, making it a great candidate for a partial view
| end | ||
| end | ||
|
|
||
| describe "spotlight" do |
There was a problem hiding this comment.
There's potential for edgecase testing here as well. What should happen when there's a tie? What should happen if there are no votes yet?
| vote = Vote.create(work_id: media, user_id: user) | ||
| vote2 = Vote.create(work_id: media, user_id: user_two) |
There was a problem hiding this comment.
| vote = Vote.create(work_id: media, user_id: user) | |
| vote2 = Vote.create(work_id: media, user_id: user_two) | |
| vote = Vote.create(work: media, user: user) | |
| vote2 = Vote.create(work: media, user: user_two) |
This test is failing because the work and user aren't successfully getting tied to these votes. This is because when you use work_id, ActiveRecord actually wants an id. You can instead change the code to what I have above.
There was a problem hiding this comment.
| vote = Vote.create(work_id: media, user_id: user) | |
| vote2 = Vote.create(work_id: media, user_id: user_two) | |
| vote = Vote.create(work_id: media.id, user_id: user.id) | |
| vote2 = Vote.create(work_id: media.id, user_id: user_two.id) |
You may have seen this before. This would also work.
| # @user = User.find_by(id: session[:user_id]) | ||
| # @username = @user.username | ||
|
|
||
| if @user.nil? |
There was a problem hiding this comment.
This will always redirect because the above 2 lines are commented out. That's why the controller tests is failing.
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?Assignment Submission: Media Ranker
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection
sessionandflash? What is the difference between them?