-
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 - Becca #39
base: master
Are you sure you want to change the base?
Space - Becca #39
Conversation
…ented get_category method in Work model.
… model to find spotlight media.
…on on works controller.
…l to render flash[:error_messages] from controller.
…works local to _work_table.
Css/styles
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
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
SummaryNicely done, this is really outstanding work. You hit all the learning goals. Well done. Take a look at my comments and let me know what questions you have. |
|
||
resources :users, only: [:index, :show, :new] | ||
|
||
get '/homepages', to: 'homepages#index', as: 'homepages' |
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.
Since you have the root path going to homepages#index, why do you need this additional route?
expect(Vote.all.count).must_equal @previous_vote_count | ||
end | ||
|
||
it "is invalid for a user to vote more than once on the same work" do |
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.
👍
require "test_helper" | ||
|
||
describe HomepagesController do | ||
# it "does a thing" do |
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.
Just noting no tests here.
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.
Also no works_controller_test
def record_not_found | ||
render file: "#{Rails.root}/public/404.html" , status: 404 | ||
end |
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!
else | ||
flash[:error] = "A problem occurred: Could not create #{@work.category}" | ||
flash[:error_messages] = @work.errors.messages | ||
render :new |
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 should also include a status code
render :new | |
render :new, status: :bad_request |
else | ||
flash[:error] = "A problem occurred: Could not update #{@work.category}" | ||
flash[:error_messages] = @work.errors.messages | ||
render :edit |
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.
render :edit | |
render :edit, status: :bad_request |
return self.where(category: category_name).includes(:votes).max_by(num_category_works) { | ||
|work| work.votes.count | ||
} |
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.
Just noting it's better to sort the works at the database-level with things like .order
as Postgres is more efficient at filtering and sorting records than Ruby/Rails are.
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
most_recent_vote_date
custom model instance method on the works model to use in the spotlight method in case of a tie for top voted work. Themost_recent_vote_date
method returns the most recent date on which a user voted, which made it possible to implement tie-breaking logic per the demo site.votes.yml
file for two different votes on the same work. This allowed me to see that the most recent vote date was returned instead of the earlier one. As an edge case, I tested what would happen if a work did not have any votes, in which case I return an old dummy date (May 20, 1965). Doing this allowed me to still do the comparison of dates even if a work didn't have a vote, vs. trying to compare a date with nil.session
andflash
? What is the difference between them?