Skip to content

Conversation

@Jcornick21
Copy link

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote.
Describe how you approached testing that model method. What edge cases did you come up with?
What are session and flash? What is the difference between them?
Describe a controller filter you wrote.
What was one thing that you gained more clarity on through this assignment?
What is the Heroku URL of your deployed application?
Do you have any recommendations on how we could improve this project for the next cohort?

@droberts-sea
Copy link

Media Ranker

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes
Comprehension questions no - ಠ_ಠ
General
Rails fundamentals (RESTful routing, use of named paths) yes - many extra routes
Semantic HTML yes
Errors are reported to the user some - problems with voting are, but validation failures are not
Business logic lives in the models some - most of the interesting business logic (ordering votes, top 10, media spotlight) is not yet implemented
Models are thoroughly tested, including relations, validations and any custom logic no
Wave 1 - Media
Splash page shows the three media categories no
Basic CRUD operations on media are present and functional some - lots of work outstanding here
Wave 2 - Users and Votes
Users can log in and log out kind of - see inline
The ID of the current user is stored in the session yes
Individual user pages and the user list are present yes, though not complete
A user cannot vote for the same media more than once yes
All media lists are ordered by vote count no
Splash page contains a media spotlight no
Media pages contain lists of voting users no
Wave 3 - Styling
Foundation is used appropriately no
Look and feel is similar to the original no
Overall

This is a good start, but there's a lot missing from this assignment. Most of the core functionality of the site (CRUD on works, logging in, voting) is there, which is no small thing. However, I'm worried the following learning goals were missed:

  • Reporting information to the user
  • Styling a complex rails site and working with a CSS framework
  • Building the complex model logic needed for the main page
  • Model testing

The first two are around building a cohesive user experience. Since you the developer are also the first user of the site, putting at least some work into this early is often good for both morale and dev velocity. For example, always reporting validation failures whenever you build a form can save you from spending a bunch of time chasing down a "bug" that was really just a typo in your input.

Testing is a difficult skill to master but it's also an essential one, both because it allows you to check that your code is doing the right thing, and because it forces you to step back from your code and think about it from the outside, asking questions like

  • How do I call this method?
  • What context/parameters does it need?
  • What is it supposed to return?
  • What kinds of input would cause a problem, and what will it do?

Being able to reason about your code in this way will make you a much stronger engineer, which is why testing is such an important part of our curriculum.

Fortunately, all of these are things you'll have ample opportunity to practice on bEtsy - please make sure you're finding opportunities to work on them. For example, you should go through right now and make sure that all your site's forms are reporting validation errors to the user. If you need early feedback on test cases I'd be happy to provide it.

I know you've been putting in a lot of hours recently. Keep up that hard work and dedication, and you'll get to where you need to be.

resources :users

get '/login', to: 'sessions#new', as: 'login'
post '/login', to: 'sessions#create'

Choose a reason for hiding this comment

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

I don't think you need all 7 restful routes for users - only index and show are needed for this project. sessions#new and sessions#create cover the workflow of making a new user, and editing or destroying a user aren't part of the requirements.

@@ -0,0 +1,14 @@
<%= form_for @work do |f| %>
<%= f.label :work_type %>
<%= f.text_field :category %>

Choose a reason for hiding this comment

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

Instead of a text box, you should use a dropdown here so the user has no chance of making a mistake.

if @work.save
redirect_to work_path(@work.id)
end

Choose a reason for hiding this comment

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

The if statement on line 14 doesn't have an else, for if the work failed to save. That means you don't have any way to report validation failures to the user, nor do you give them an opportunity to correct their error.

resources :votes

resources :works do
resources :votes, only: [:create]

Choose a reason for hiding this comment

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

Do you need any routes for votes other than create?

Also, you should either have a nested or un-nested version of votes#create, not both.

end

def update
user.assign_attributes(user_params)

Choose a reason for hiding this comment

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

You should only need index and show in this controller, since most of the other user workflows are handled by the SessionsController or not supported at all.

<% if model.errors.messages.any? %>
<section class="alert callout">
<h3>There were some problems</h3>
<ul>

Choose a reason for hiding this comment

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

You've got this partial do display validation errors, but you're only using it for votes. You should use it for users and works as well.

def self.albums
Work.where(category: "album")

end

Choose a reason for hiding this comment

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

I like that you've isolated these as model methods. That means if you were to, say, order them by vote count, you could do so here without having to change your view code at all.


def update
work.assign_attributes(work_params)

Choose a reason for hiding this comment

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

The update method doesn't work! I suspect you want @work on line 26.

class User < ApplicationRecord
has_many :votes
validates :name, presence: true
validates :votes, uniqueness: {scope: :work}

Choose a reason for hiding this comment

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

I had to disable the validations on lines 3 and 4 to log in.

On line 3, I suspect you want to be validating user_name instead of name.

Not sure what's up with line 4, especially since you validate vote uniqueness in the Vote model.

belongs_to :user
belongs_to :work

validates :user, uniqueness: {scope: :work}

Choose a reason for hiding this comment

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

Good work getting this tricky validation sorted out.

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