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

Carly Reiter - Edges - Media Ranker #25

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

Conversation

CarlyReiter
Copy link

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote. I wish I could say that I wrote one, but I didn't. I'm pretty lost when it comes to business logic and connecting it to the other pieces of rails....
Describe how you approached testing that model method. What edge cases did you come up with? See above.
What are session and flash? What is the difference between them? They are both hash-like beings, but flash only lasts for one request cycle, while session lasts until the user is logged out and/or the session times out with the browser.
Describe a controller filter you wrote. I wrote one in the works controller that replaced all of the find_by id lines.
What was one thing that you gained more clarity on through this assignment? MODEL LOGIC, for sure.
What is the Heroku URL of your deployed application? https://media-ranker-carly.herokuapp.com/
Do you have any recommendations on how we could improve this project for the next cohort? It's a ton and, even though I felt like I learned a lot about general rails deployment, flash, session, and bootstrap, I still feel quite defeated about not even coming close to finishing the project. The first wave was essentially all that my partner and I did the entire project last week, plus more. That took me nearly the entire week to do on its own this time. Additionally, there has been VERY little modelling of model logic and its connection to the other pieces of a rails program. This would have been very helpful.

@tildeee
Copy link

tildeee commented Oct 30, 2018

Media Ranker

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene x
Comprehension questions x
General
Rails fundamentals (RESTful routing, use of named paths) routes aren't quite where I want them to be
Views are well-organized (DRY, use of semantic HTML, use of partials)
Errors are reported to the user x flash messages showed up for logging in and out
Business logic lives in the models Working with Works for either formatting, categorizing, sorting, or finding the top ten or top one is what we expected for business logic
Models are thoroughly tested, including relations, validations and any custom logic relations and validations are well tested
Wave 1 - Media
Splash page shows the three media categories
Basic CRUD operations on media are present and functional x, looking at the detail page of a work is broken because it is trying to find a path named upvote_path which doesn't exist. Removing the call for this fixes it.
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
All media lists are ordered by vote count
Splash page contains a media spotlight
Wave 3 - Users and Votes
Media pages contain lists of voting users
Individual user pages and the user list are present x
Optional - Styling
Bootstrap is used appropriately x
Look and feel is similar to the original x
Overall

Hi Carly! You hit the following learning goals really well:

  • Use session for logging in and logging out
  • Use flash to give feedback to the user
  • Use bootstrap to recreate a style
  • Work on CRUD for a model
  • Testing validations and relations on a model
  • Create the relations between Vote, User, and Work

I'm sure you know, but you didn't get to the following:

  • Create only the minimum number of RESTful or nested routes as we expected
  • Successfully use a custom route for upvoting, which slices through routes, controllers, models, and views
  • Filter, sort, work with lists of Works for top ten/spotlight via business logic (and test them)

This was a tough project! I definitely think that a lot of the submitted code is good. I have a feeling that some of this project was a time crunch, and some of it was working through understanding how to flex Rails to your will in a more custom manner. Maybe the situation has changed now that we've gone a few weeks. Let's have a talk about this sometime soon-- feel free to bring your questions!

I'm going to make a few comments on some things that I think could be tidied up, or some ways to look at this code in a new perspective. I understand that this feedback may be very late-- sorry about that

class VotesController < ApplicationController

def index
@votes = Vote.all
Copy link

Choose a reason for hiding this comment

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

When do we go down this path?

@vote = Vote.find_by(id: params[:id])
if @vote.nil?
head :not_found
end
Copy link

Choose a reason for hiding this comment

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

Hm, which requirement/user story were you working on when trying to view a specific vote?

@@ -0,0 +1 @@
<h1>Edit users page</h1>
Copy link

Choose a reason for hiding this comment

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

is this view, or the users/new view, ever used?

<section>
<%= link_to "Back to media ranks", works_path, class: "btn btn-primary" %>
<%= link_to "Edit", edit_work_path, class: "btn btn-primary" %>
<%=link_to "Upvote", upvote_path, method: :post, class: "btn btn-primary" %>
Copy link

Choose a reason for hiding this comment

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

Just an fyi, the syntax I used to comment this code out is:

<%#link_to "Upvote", upvote_path, method: :post, class: "btn btn-primary" %>

resources :votes, only: [:index, :create, :update]
member do
post 'upvote'
end
Copy link

Choose a reason for hiding this comment

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

interesting, but not quite what we want. You're correct that you want to nest something about post requests and upvoting within a work, because then we get to make a request that is inherently related to a work (and it'll definitely have a work ID associated with it when it's nested!)... You have something closer to what we expected below in this file, where you nested resources :votes into resources :users. In general, we know that vote are tied to both a user and a work, so therefore at the time of creating a vote (aka the "upvote"), we need to have a way to reference a work and reference a user. Using routes as a mechanism for having a way to reference a work is a good strategy.


resources :works do

end
Copy link

Choose a reason for hiding this comment

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

When you have resources :works above this block already declared, you don't need to re-declare it empty down here. The above block accomplishes the whole "making routes for `works" bit!


resources :users do
resources :votes, only: [:index, :create]
end
Copy link

Choose a reason for hiding this comment

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

Overall in this file, you're playing around and experimenting with how to make the votes paths. Ultimately, I'd say: we don't want any routes paths that are on their own (not-nested), and we don't need the "create" path for a vote nested under a user. (There's also no requirement that would be better off if we nested the votes index route under a user, too, but I could see someone argue for it.)


resources :sessions, only: [:new, :create]

post '/sessions/logout', to: 'sessions#logout', as: 'logout'
Copy link

Choose a reason for hiding this comment

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

Nice! You had a specific action and URL that you wanted to make as a custom route, you knew which controller and action it went to, and the name you would refer to it within the app code.

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