Skip to content

Water - Sophia's task list#52

Open
SoCodeDo wants to merge 13 commits intoAda-C14:masterfrom
SoCodeDo:master
Open

Water - Sophia's task list#52
SoCodeDo wants to merge 13 commits intoAda-C14:masterfrom
SoCodeDo:master

Conversation

@SoCodeDo
Copy link

@SoCodeDo SoCodeDo commented Nov 3, 2020

Task List

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe in your own words what the Model is doing in Rails It can add database records, or find data that you're looking for.
Describe in your own words what the Controller is doing in Rails It makes the model data available to the view so it can display that data to the user.
Describe in your own words what the View is doing in Rails It is an ERB program that shares data with controllers through mutually accessible variables.
Describe an edge-case controller test you wrote # will finish later it is late at night
What is the purpose of using strong params? (i.e. the params method in the controller) # will finish later it is late at night
How are Rails migrations related to Rails models? # will finish later it is late at night
Describe one area of Rails that are still unclear on # will finish later it is late at night

@SoCodeDo
Copy link
Author

SoCodeDo commented Nov 3, 2020

I still need to work on the 'mark as completed' link, and debug the two errors. But I chose to stop last night and just turn it in.

Copy link

@jmaddox19 jmaddox19 left a comment

Choose a reason for hiding this comment

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

As an initial note, I am really glad that you made the choice to turn in what you had even though it isn't complete so you can move forward. Hopefully the comments here will be helpful as you get more into Ride Share Rails. :)

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 ✔️ I love that you labeled messages with a wave number but also included a descriptive message
Routes follow RESTful conventions ✔️ Yes, though it could be cleaned up by using the resources syntax
Uses named routes (like _path) ✔️
Creates Models and migrations ✔️
Creates styled views
Handles errors like nonexistant tasks Not in an appropriate way, for the show action. See my inline comment in show action. Other actions do handle it with an appropriate redirect
Uses form_with to render forms in Rails ✔️

Functional Requirements/Manual Testing

Functional Requirement yes/no
Successfully handles index & show ✔️ For the most part yes, but it is limiting that there isn't any way for a user to click a link from the index page to get to the show page. (It would be appropriate to make the tasks click-able.)
index & show tests pass ✔️
Successfully handles: New, Create ✔️
New, Create tests pass ✔️
Successfully handles: Edit, Update ✔️
Edit, Update tests pass with valid & invalid task ids ✔️
Successfully handles: Destroy, Task Complete See inline comments for more details
Tests for Destroy & Task Complete include tests for valid and invalid task ids

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 5+ in Code Review && 6+ in Functional Requirements
Yellow (Approaches Standards) 3+ in Code Review && 5+ in Functional Requirements, or the instructor judges that this project needs special attention ✔️
Red (Not at Standard) 0-2 in Code Review or 0-4 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

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

end
end

def destroy
Copy link

@jmaddox19 jmaddox19 Nov 3, 2020

Choose a reason for hiding this comment

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

As mentioned in the routes.rb comment, this action is not being reached because the name in routes.rb is not the same as it is here.

it 'will destroy to permanently remove a task' do
task
expect {
destroy task_path(task.id)

Choose a reason for hiding this comment

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

This test and the test below are failing because the proper HTTP verb is "delete" rather than "destroy".

Suggested change
destroy task_path(task.id)
delete task_path(task.id)

Choose a reason for hiding this comment

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

Hence I get the following error

NoMethodError: undefined method `destroy'

get '/tasks/:id/edit', to: 'tasks#edit', as: 'edit_task'
patch '/tasks/:id', to: 'tasks#update'
get '/tasks/:id/confirm_delete', to: 'tasks#confirm', as: 'confirm_task'
delete '/tasks/:id', to: 'tasks#delete', as: 'delete_task'
Copy link

@jmaddox19 jmaddox19 Nov 3, 2020

Choose a reason for hiding this comment

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

The action is referred to as delete here but it is named destroy in the controller. It is important that the names line up for Rails to be about to route the request correctly.
Convention would be to name it destroy but as long as they match, it will work.
Also, as we talked about during roundtable today, using as on this line is unnecessary because the path is already named on line 8.

Suggested change
delete '/tasks/:id', to: 'tasks#delete', as: 'delete_task'
delete '/tasks/:id', to: 'tasks#destroy'


def destroy
@task = Task.find_by(id: params[:id])
task_params = params.require(:task).permit(:name, :description, :completed_at)

Choose a reason for hiding this comment

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

Once you fix the above, you will see the following error:

ParameterMissing: param is missing or the value is empty: task

This is because none of these params are given during a delete request. Only the id is given, so this line is unnecessary.

Suggested change
task_params = params.require(:task).permit(:name, :description, :completed_at)


def update
@task = Task.find_by(id: params[:id])
task_params = params.require(:task).permit(:name, :description, :completed_at)

Choose a reason for hiding this comment

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

This line is used in several methods and could be DRYed up by creating a private task_params method like we demonstrate with AdaBooks

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