Skip to content
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

goeun edges media stanker #46

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open

Conversation

goeunpark
Copy link

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote. In the Work method, I created self.spotlight and `self.sorted'. They do nearly the same thing, which is to sort all Works by the length of the votes array (aka- how many votes each work has) except spotlight returns the first of that array .
Describe how you approached testing that model method. What edge cases did you come up with? (haven't gotten around to it)
What are session and flash? What is the difference between them? Flash is a Rails hash that is intended for single-use to denote overall success or failure when submitting a form by using cookies. Session also uses cookies to keep track of a stage such as being a @logged_in_user until user logs out or closes the browser.
Describe a controller filter you wrote. find_work in Work and find_user in user finds the work and I don't have to repeat it in 5 different places.
What was one thing that you gained more clarity on through this assignment? I had formerly kept each model very distinct from each other (such as, user instances and business are only the user controller and user view and etc etc) but when I was trying to get the Vote mechanism running, it made sense to create it in the SessionsController's create. IDK if I'm allowed to do this? But if I am, the lesson would be that Controllers are there to be designated locations and guides but it's not technically confining
What is the Heroku URL of your deployed application? http://gp-media-ranker.herokuapp.com/
Do you have any recommendations on how we could improve this project for the next cohort? Not really, disclaimer: I'm turning this in late because I was disorganized, not because I was crushed for time

@tildeee
Copy link

tildeee commented Oct 18, 2018

Media Ranker

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene x
Comprehension questions x -- yes -- Controllers are not confining, and you are allowed to break the pattern! Glad you saw that learning
General
Rails fundamentals (RESTful routing, use of named paths) x
Views are well-organized (DRY, use of semantic HTML, use of partials) x
Errors are reported to the user x
Business logic lives in the models x
Models are thoroughly tested, including relations, validations and any custom logic x
Wave 1 - Media
Splash page shows the three media categories x
Basic CRUD operations on media are present and functional x
Wave 2 - Users and Votes
Users can log in and log out x
The ID of the current user is stored in the session x
A user cannot vote for the same media more than once x
All media lists are ordered by vote count x
Splash page contains a media spotlight x
Wave 3 - Users and Votes
Media pages contain lists of voting users :( Nope
Individual user pages and the user list are present User list present, but no individual user pages
Optional - Styling
Bootstrap is used appropriately x
Look and feel is similar to the original similar... and better! The styling looks great; wonderful job there.
Overall

Wonderful job overall Goeun! In general, this project meets most of the requirements and it looks great too. I'm also really glad to see it deployed.

Unfortunately, I saw a few project requirements that I was looking for missing in this project, aka:

  • Individual pages for user
  • Tables of users who have voted for a specific work on a work page

Similarly, a large theme of my comments on your code will be about hoping to refactor your code to be less hard-coded. This project's code relies a lot on the idea that there will always be the three categories Album, Book, and Movie. It'd be great to see code that is more extensible than that.

Other than that, the code is really great, and I'm glad to see it pretty much all complete... even if you mentioned it was a submission of lateness and disorganization. Definitely meets the requirements-- good work overall

</h2>

<ul class="list-group top-ten-list">
<% i = 0 %>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are using this variable i to limit the loop to under ten. It definitely works! However, there may be better ways to do this: First of all, you could consider a 10.times loop with this... Or... My main concern is that there is a lil bit of logic in this view that I'm not comfortable with (aka... the looping part is fine, but the limiting to ten!) You might want to switch this logic into a model or controller ;) That would be my favorite solution!

class User < ApplicationRecord
has_many :votes, dependent: :nullify

validates :username, presence: true, uniqueness: true, format: {with: /\A[-_a-z0-9]+\Z/}, length: {maximum: 15}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the validations! Definitely not part of the project requirements though. But hey-- you did it-- and tested it! Just want to call out that it was work that wasn't necessarily asked for.

<%= yield %>

<footer>
don't steal me, k thnx
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wao no imma steal K THX U

<li> underscores (_) </li>
</ul>
</p>
<%= form_with method: :post, url: sessions_path do |f| %>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay! A nice form_with with explicit method + url. Breaks the pattern of giving it a model, but definitely works/useful for us in this situation!

<div class="form-group">
<%= f.label :category %>
<div class="col-md-8">
<%= f.select(:category, options_for_select([['Movie', 'movie'], ['Album', 'album'], ['Book', 'book']]))%>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ends up being a good, working solution for now... But what if the categories became larger than 3 items? what if there were 10 categories? 100? It'd be nice if we found a way to make this array of arrays into a collection defined in the controller

<%= render partial: 'layouts/form_errors',
locals: {model: @work} %>

<%= render partial: "form", locals: {directions: "Complete this form to edit media:", action_button: "Edit Media"} %>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love these locals ;)

</thead>
<tbody>
<% @works.sort.each do |work| %>
<% if work.category == "album" %>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three tables end up being identical besides the category that you check on. There are a few ways to refactor this. One way is to use partials: You've used partials before with different things passed into it... (aka the form with different local messages for buttons) Could you do the same for this table? Let me know if you have questions!

<% end %>
</tbody>
</table>
<br >
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try not to use a <br /> tag if possible -- brs are for line breaks, which is a display/layout thing!

🎬
<% else @work.category == "book"%>
📖
<% end %>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is view logic! I'm not mad about it, but just know: this can be solved with either controller logic... or CSS ;O

# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html

root 'homes#index'
get '/homes', to: 'homes#index'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nice to name this path, so you can reference it in the line above

require "test_helper"
require 'pry'

describe Work do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job getting tests on relations and validations -- What about your custom methods?

work = works(:nemo)

work.votes.length.must_equal 3
work.votes[0].must_equal votes(:one)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to check the order of what comes into the votes array? I'm not sure that it's important that we do. However, if you wanted to do this, I might instead check with

work.votes.include?( votes(:one) ).must_equal true

it 'is invalid with a non-unique title' do
repeat = Work.new(
category: 'movie',
title: 'Finding Nemo',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be nice to re-inforce the point of this test by referencing the title of an existing work (defined in fixtures), aka

title: works(:nemo).title,

end

it 'is invalid if publication date is greater than 2018' do
w = works(:heartburn)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I LOVE THIS VALIDATION! Not required, but still really goood!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants