-
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 - kate #31
base: master
Are you sure you want to change the base?
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...?)
|
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.
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.
app/controllers/votes_controller.rb
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Editing a vote is kind of a weird thing to do.
I would have omitted this action.
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.
corrected in file.
app/controllers/works_controller.rb
Outdated
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant these flash
messages to be in create
.
app/controllers/works_controller.rb
Outdated
@work = Work.find_by(id: params[:id]) | ||
|
||
if @work.nil? | ||
redirect_to root_path | ||
return | ||
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.
This kind of repeated logic should live in a controller filter.
app/models/user.rb
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is equivalent to doing user.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.
updated in code
app/models/work.rb
Outdated
if count > 0 | ||
return false | ||
end | ||
return true |
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.
if count > 0 | |
return false | |
end | |
return true | |
return count == 0 |
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.
edited in code
<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.
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 meant to leave this <h2>
open if there was no spotlight.
test/models/user_test.rb
Outdated
# Assert | ||
expect(found_user.username).must_equal "test_user" |
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.
Indentation.
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
session
andflash
? What is the difference between them?