space - kate#31
Conversation
Users controller
Works controller
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...?)
|
kaidamasaki
left a comment
There was a problem hiding this comment.
It looks like you had a difficult time with this.
Much of what was here was reasonable but it looks like you ran out of time while working on this. For example your controllers were of rather high quality.
Things to focus on to make sure you solidify your learning based on this are resources, controller filters and model relationships.
| def edit | ||
| @vote = Vote.find_by(id: params[:id]) | ||
|
|
||
| if @vote.nil? | ||
| redirect_to root_path | ||
| return | ||
| end | ||
| end |
There was a problem hiding this comment.
Editing a vote is kind of a weird thing to do.
I would have omitted this action.
| @work = Work.find_by(id: params[:id]) | ||
| flash[:success] = "#{@work.category} added successfully" | ||
| if @work.nil? | ||
| flash.now[:error] = "Something happened. Book not added." | ||
| render :new, status: :bad_request | ||
| #head :not_found | ||
| return | ||
| end |
There was a problem hiding this comment.
I think you meant these flash messages to be in create.
| @work = Work.find_by(id: params[:id]) | ||
|
|
||
| if @work.nil? | ||
| redirect_to root_path | ||
| return | ||
| end |
There was a problem hiding this comment.
This kind of repeated logic should live in a controller filter.
| def get_vote_count | ||
| #filter Vote Db by work_id = this.id | ||
| count = Vote.where(user_id: self.id).count | ||
| return count | ||
| end |
There was a problem hiding this comment.
This method is equivalent to doing user.votes.count.
| if count > 0 | ||
| return false | ||
| end | ||
| return true |
There was a problem hiding this comment.
| if count > 0 | |
| return false | |
| end | |
| return true | |
| return count == 0 |
| <span class="spotlight__header--prefix">Media Spotlight</span> | ||
| <% if @work_spotlight != nil %> | ||
| <%= link_to @work_spotlight.title, work_path(@work_spotlight.id), class:'spotlight__link-to' %> by <%= @work_spotlight.creator%> | ||
| </h2> |
There was a problem hiding this comment.
I don't think you meant to leave this <h2> open if there was no spotlight.
| # Assert | ||
| expect(found_user.username).must_equal "test_user" |
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?