-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Space - Liv #42
base: master
Are you sure you want to change the base?
Space - Liv #42
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
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users doesn't need all of the routes that resources:
provides. you should aim to limit the number of routes in a project!
<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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NICE
Assignment Submission: Media Ranker
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection
session
andflash
? What is the difference between them?