Space - Liv#42
Open
mulhoo wants to merge 33 commits into
Open
Conversation
Media RankerFunctional Requirements: Manual Testing
Major Learning Goals/Code Review
Previous Rails learning, Building Complex Model Logic, DRYing up Rails Code
Testing Rails Apps
Overall Feedback
|
dHelmgren
reviewed
Jun 4, 2020
Comment on lines
+8
to
+14
| return nil if Vote.count == 0 | ||
|
|
||
| top_work = Work.all.max_by do |work| | ||
| work.votes.count | ||
| end | ||
|
|
||
| return top_work |
There was a problem hiding this comment.
This doesn't seem to work with your starting seeds. It doesn't return a top media when one category is empty/there are no votes.
| Rails.application.routes.draw do | ||
| root 'homepage#index' | ||
| resources :works | ||
| resources :users |
There was a problem hiding this comment.
Users doesn't need all of the routes that resources: provides. you should aim to limit the number of routes in a project!
Comment on lines
+36
to
+55
| <section class="top-ten_list-container"> | ||
| <h3 class="top-ten__header">Top Books</h3> | ||
| <ul class='list-group top-ten__list'> | ||
| <% @sort_books[0..9].each do |book| %> | ||
| <ol class='list-group-item'> | ||
| <%= link_to book.title, work_path(book.id), class:"link_to" %>, | ||
| <%= book[:creator] %> | ||
| (<%= book[:publication_year] %>) | ||
| <div class = "votes"> | ||
| <%= Vote.where(work_id: book.id).count =%> votes | ||
| </div> | ||
| </ol> | ||
| <% end %> | ||
| </ul> | ||
| </section> | ||
|
|
||
| <section class="top-ten_list-container"> | ||
| <h3 class="top-ten__header">Top Albums</h3> | ||
| <ul class='list-group top-ten__list'> | ||
| <% @sort_albums[0..9].each do |album| %> |
There was a problem hiding this comment.
You repeat this HTML 3 times, making it a good candidate for a view partial. They aren't just for forms!
| @@ -0,0 +1,16 @@ | |||
| class User < ApplicationRecord | |||
| has_many :votes | |||
There was a problem hiding this comment.
This is where you can put the restriction for limiting how many times a user can vote on works.
| @@ -0,0 +1,89 @@ | |||
| class UsersController < ApplicationController | |||
| before_action :require_login, only: [:show] | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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?