Conversation
…iews not yet created
…rks model test started continue on diff branch
Media RankerWhat We're Looking For
|
| get 'sessions/login', to: 'sessions#new' | ||
| delete 'sessions/destroy', to: 'sessions#destroy', as: 'logout' | ||
|
|
||
| resources :works, :users |
There was a problem hiding this comment.
I don't think you need all 7 restful routes for users - only index and show are needed for this project.
| </tr> | ||
| <tbody> | ||
| <% @movies.each do |movie| %> | ||
| <tr> |
There was a problem hiding this comment.
You have the same code to show a list of works repeated 3 times. Could you use a view partial or a loop to DRY this up?
|
|
||
| def upvote(user) | ||
| #Vote.create(user: user, work: self) | ||
| votes.create(user: user) |
There was a problem hiding this comment.
Create will return a Vote regardless of whether it succeeds or fails, its up to you to interpret the data! This is why your upvotes don't add more votes to the total, but the error messaging is incorrect.
| @@ -0,0 +1,6 @@ | |||
| class Vote < ApplicationRecord | |||
| belongs_to :user | |||
| belongs_to :work | |||
There was a problem hiding this comment.
You can't delete a work that has votes! This is because you've created a link between the two tables at the database level, and deleting the work would leave behind invalid votes. You might want to check out the dependent argument to has_many.
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?