Skip to content

Conversation

@FreeMonkey19
Copy link

Task List

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe in your own words what the Model is doing in Rails The Model is the 'business' piece of the MVC. It handles logic and data. Talks to the db.
Describe in your own words what the Controller is doing in Rails The Controller is like the 'brain' of the app. It is the middleman between User, Views and the Model.
Describe in your own words what the View is doing in Rails The View displays data to the User that a method has collected. Every method in the controller has a matching html.erb file.
Describe an edge-case controller test you wrote I wrote nominal cases.
What is the purpose of using strong params? (i.e. the params method in the controller) Strong params are a security feature. We use them to give permission for which form-data is allowed in our Models.
How are Rails migrations related to Rails models? Migrations manipulate the db schema (similar to version control for the db) and Models manipulate table data.
Describe one area of Rails that are still unclear on I'm a day and a half behind on lectures/videos. Partial views are not clear nor is the refactoring. (yet)

@tildeee
Copy link

tildeee commented May 8, 2020

Task List

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
At least 6 commits with meaningful commit messages ✔️
Routes follow RESTful conventions ✔️
Uses named routes (like _path) You did 99% of the time, but you did not in tasks_controller.rb line 68
Creates Models and migrations ✔️
Creates styled views
Handles errors like nonexistant tasks ✔️, Non-existant tasks redirect back to index page
Uses form_with to render forms in Rails ✔️

Functional Requirements/Manual Testing

Functional Requirement yes/no
Successfully handles index & show Kind of... ✔️ your site actually doesn't let users create new tasks unless there is a task already there.
index & show tests pass ✔️
Successfully handles: New, Create ✔️
New, Create tests pass ✔️
Successfully handles: Edit, Update ✔️
Successfully handles: Destroy, Task Complete ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 5+ in Code Review && 5+ in Functional Requirements
Yellow (Approaches Standards) 3+ in Code Review && 4+ in Functional Requirements, or the instructor judges that this project needs special attention
Red (Not at Standard) 0-2 in Code Review or 0-3 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging, or the instructor judges that this project needs special attention ✔️ See my notes -- namely I have concerns about your project setup

Additional Feedback

Hi Charlotte! Great work on your Task List! (I like the name of it a lot)

Overall, your Rails code looks good, and you definitely have a functional Task List! Great work on accomplishing all of those features!!

These are the main comments I have:

  • I'm leaving a few comments and suggestions on your code on how to improve it and keep it more Rails-y!
  • There are a few things missing that I look forward to getting to see you practice in a future project:
    • Seeing tests on those edge cases on update, all cases on destroy, and all cases on custom actions (like mark complete) (I know this was optional!)
    • Styling!
    • Usability improvements for the overall site-- your flow for the "home" route is confusing, and I was lost in your project! You'll see this in your comments, but also I can't see the tasks unless I use the Rails console! Similarly, it's completely hidden from the user if a task is completed or not, unless they know that they should be looking for a blank or filled in task completion date. Details like this help your product be more usable. :)
    • refactoring to use strong params and resources with routes!
  • The biggest thing: I suspect that your project is using SQLite as a database, when we are hoping to set up our projects to use postgresql as a database. I think that you're using a different database because I see different database logs/files compared to what I'm expecting. We setup the postgresql database in the Rails template lesson. It feels important to make sure you're on the right database, so take a second to see what your Rails template looks like, and feel free to ask a classmate or me or the instructors for any help.

Let me know what else we can talk about or ask about!

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Descriptive/Readable
Concise
Logical/Organized

Comment on lines +47 to +49
@today = Date.today
@task = Task.find_by(id:params[:id])
@task.completed_at = @today
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since today is a variable that only matters in this action, you can leave off the @ and leave it as the local variable today! (You would make it an instance variable @today if you specifically wanted to share it with the view. However, the view that you redirect to at the end of this method doesn't need an @today instance variable shared with it!)

You may even consider just refactoring it to @task.completed_at = Date.today


def mark_complete
@today = Date.today
@task = Task.find_by(id:params[:id])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if there is no Task found? :)

@task = Task.find_by(id:params[:id])
@task.completed_at = @today
@task.save
redirect_to task_path
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subtleties in variables: task_path is the named path that goes to the show page for one given task. tasks_path is the named path that goes to the index page for all tasks. task_path normally takes in a task as a parameter, so it'll be more clear to say redirect_to task_path(@task) or redirect_to task_path(@task.id)

@task = Task.find_by(id:id)

if @task.nil?
redirect_to '/tasks'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, you are redirecting directly to a url '/tasks'. In the small chance that this would change, it'll be better to use named paths. In this case, you'd use the named path tasks_path (much like what you did in the update method)!

<h1>All Tasks</h1>
<h3>Click on a Task name to view the details:</h3>

<% if @tasks.length > 0 %>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your section to add a new task is within this conditional if @tasks.length > 0. That means you can't add any tasks if there are no tasks existing!

# see https://guides.rubyonrails.org/routing.html

# verb 'path' to: 'name of controller#action'
get '/', to: 'tasks#home', as: 'root'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to let yourself re-think and simplify your approach to the root path. Here, you declare the rootpath to go to the home action, which is an empty action, has an empty view, and doesn't have tests! It might be interesting for some projects to have a home action or root path of simply another action.


# Act
get task_path(task.id)
get tasks_path(task.id)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be altered-- the correct request for the show page is a GET to task_path

let (:task) {
Task.create name: "sample task", description: "this is an example for a test",
completed_at: Time.now + 5.days
completed_at: "sample day/time for testing"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why did you change this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants