Conversation
Task ListMajor Learning Goals/Code Review
Functional Requirements/Manual Testing
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.
Great job! Here are a couple of ways you can clean up your future projects.
| def complete | ||
| @task = Task.find_by(id: params[:id]) | ||
| if @task.nil? | ||
| head :not_found | ||
| return | ||
| elsif @task.completed_at == "" | ||
| @task.update(completed_at: Time.now) | ||
| redirect_to tasks_path | ||
| return | ||
| else | ||
| @task.update(completed_at: "") | ||
| end | ||
| end |
There was a problem hiding this comment.
I'd generally recommend splitting actions like this into two parts in the future. One to mark complete and one to mark incomplete.
One reason is that things can get confusing if the user's computer or internet is slow. If the page takes a while to load and the user clicks the button several times you could get several requests that could potentially cancel each other out.
Where as if your endpoint doesn't toggle back and forth your task will just be marked complete several times.
| create_table :tasks do |t| | ||
| t.string :name | ||
| t.string :description | ||
| t.string :complete_at |
There was a problem hiding this comment.
In the future you should use t.datetime for columns like these.
Task List
Congratulations! You're submitting your assignment!
Comprehension Questions