-
Notifications
You must be signed in to change notification settings - Fork 47
Space - Sara N. #25
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
base: master
Are you sure you want to change the base?
Space - Sara N. #25
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future you should use t.datetime for columns like these.
Task List
Congratulations! You're submitting your assignment!
Comprehension Questions