Skip to content
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

Branches-Steph #48

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Branches-Steph #48

wants to merge 12 commits into from

Conversation

Steph0088
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 where all code that active records uses to interact with the database.
Describe in your own words what the Controller is doing in Rails THe controller sends requests to the correct place in order to return the users request.
Describe in your own words what the View is doing in Rails The view is taking the data to complete the users request and acting on it to represent it in a way the user will find useful.
Describe an edge-case controller test you wrote I don't think I wrote any edge-case tests.
What is the purpose of using strong params? (i.e. the params method in the controller) Strong params are used as a measure of security and a way to simply the creating of instances or objects.
How are Rails migrations related to Rails models? Migrations are used to make changes to the model data schema.
Describe one area of Rails that are still unclear on I am still confused on the syntax, what goes where, mostly symbols and key value pairs, when to use them as well as params. What is allowed and what isn't.

@tildeee
Copy link

tildeee commented Oct 14, 2019

Task List

What We're Looking For

Feature Feedback
Baseline
Appropriate Git Usage with no extraneous files checked in x
Answered comprehension questions x
Successfully handles: Index, Show x
Index & Show tests pass x
Successfully handles: New, Create x
New & Create tests pass x
Successfully handles: Edit, Update x
Tests for Edit & Update test valid & invalid task ids x
Successfully handles: Destroy, Task Complete x
Tests for Destroy & Task Complete include tests for valid and invalid task ids x
Routes follow RESTful conventions x
Uses named routes (like _path) x
Overall

Fantastic work on this project, Steph! Your project looks so so so good! The code is all there and works well, and your tests are all there and work well! I have no complaints about this project

I only have a few comments that are suggestions on how to refactor the code, and also some few ways to make your code more Rails-y.

Lastly, I may say that your TaskList webpages didn't have a direct link to the Task's show page, and in the future, that would be convenient for me :P

Otherwise, great work on this, and keep it up!


def show
task_id = params[:id].to_i
@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.

Consider refactoring the above two lines to either

    task_id = params[:id].to_i
    @task = Task.find_by(id: task_id)

or

    @task = Task.find_by(id: params[:id])

in order to help efficiently use local variables

end

def create
@task = Task.new(name: params[:task][:name], description: params[:task][:description], completed: params[:task][:completed])
Copy link

Choose a reason for hiding this comment

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

In the future, let's use strong params, so refactor this line to:

@task = Task.new(task_params)


def edit
task_id = params[:id].to_i
@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.

Same as my comments above in the show action, consider refactoring these two lines

@task = Task.find_by(id: params[:id])

if [email protected]?
@task.update(task_params)
Copy link

Choose a reason for hiding this comment

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

Nice use of strong params here!


def toggle_complete
task_id = params[:id].to_i
@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.

Same as above-- consider refactoring to use task_id or to get rid of it :)

#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
raic
Copy link

Choose a reason for hiding this comment

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

Nitpick: This stray code was left here and was broken. Watch out!


# Assert
#Step Three once you change the fields, check to see if they are different than original
#expect(Book.find_by(id: existing_book.id).title).must_equal "Name that you changed book to"
Copy link

Choose a reason for hiding this comment

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

Not sure if this would help, but maybe if you can spend the time to remove these comments before submission, or find a way to reword them, that may help with solidfying your understanding


existing_task = Task.create(name: "cs fun", description: "recursion practice", completed: nil)
patch complete_path(existing_task)
expect(Task.find_by(id: existing_task.id).completed).must_be_instance_of ActiveSupport::TimeWithZone
Copy link

Choose a reason for hiding this comment

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

Nice! It may look weird, but it makes sense to me and it's what works.


existing_task = Task.create(name: "cs fun", description: "recursion practice", completed: nil)
patch complete_path(existing_task)
expect(Task.find_by(id: existing_task.id).completed).must_be_instance_of ActiveSupport::TimeWithZone
Copy link

Choose a reason for hiding this comment

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

This test would be perfect and complete with an assertion to check the response, like must_redirect_to or something

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