Skip to content

Conversation

@angethuy
Copy link

@angethuy angethuy commented May 5, 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 Active Record provides the "Model" layer in Rails. As the Model, it establishes objects, their data, and the relationships between objects. It also provides the methods by which we can interface with the database to retrieve and modify data.
Describe in your own words what the Controller is doing in Rails It's doing ALL THE HARD WORK! The Controller defines actions and performs them in response to incoming requests by accessing and processing data it retrieves from our model, and making that data available for Views.
Describe in your own words what the View is doing in Rails the View is rendering HTML, it can also use Embedded Ruby to access and lightly manipulate data from the Controller.
Describe an edge-case controller test you wrote The test that asserts "will redirect to the root page if deleting an invalid task" is an edge-case test because it covers the unlikely case of the user trying to delete a task that doesn't exist.
What is the purpose of using strong params? (i.e. the params method in the controller) Strong params provide data validation to protect against malformed data.
How are Rails migrations related to Rails models? You can use migrations to modify your database to reflect changes in the models.
Describe one area of Rails that you are still unclear on. I am struggling to manage the syntax of routes and their verbs. I suspect it's a matter of muscle memory and pattern recognition, but right now I have to slow down and really parse the structure of everything I'm writing when I'm creating a new route and linking those routes to actions in their respective views.

@CheezItMan
Copy link

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) ✔️
Creates Models and migrations ✔️
Creates styled views ✔️, somewhat styled
Handles errors like nonexistant tasks ✔️
Uses form_with to render forms in Rails ✔️, nice partial view!

Functional Requirements/Manual Testing

Functional Requirement yes/no
Successfully handles index & show ✔️
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

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

Summary

Really nice work, you hit the learning goals here. A good start to Rails. The only suggestion I can make is that you could combine your mark complete and incomplete methods into one method which toggles between them.

def mark_incomplete
@task = Task.find_by(id: params[:id])
return redirect_to :task if @task.nil?
@task.update(completed_at: "")

Choose a reason for hiding this comment

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

You should probably have an if statement here.

Comment on lines +40 to +45
def mark_complete
@task = Task.find_by(id: params[:id])
return redirect_to :task if @task.nil?
@task.update(completed_at: Time.now.strftime("%d/%m/%Y"))
return redirect_to :tasks
end

Choose a reason for hiding this comment

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

Could you combine the mark_complete and mark_incomplete methods into a toggle_complate method that toggles between complete and incomplete?


def destroy
@task = Task.find_by(id: params[:id])
return redirect_to tasks_path if @task.nil?

Choose a reason for hiding this comment

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

This works, but you could also provide a 404 response here.

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>

Choose a reason for hiding this comment

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

I would strongly suggest placing navigation links for your site in this layout file. This helps dry up layout code and provides a uniform interface.

@@ -0,0 +1,12 @@
<%= form_with model: @task, class:'create-task' do |f| %>

Choose a reason for hiding this comment

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

Nice, a partial view!

@@ -0,0 +1,11 @@
<h1>Tasks</h1>
<button><%= link_to "add new task", new_task_path %></button>

Choose a reason for hiding this comment

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

instead of using a button tag, you could use button_to. It functions like link_to but makes a mini-form and makes a post request by default.

https://apidock.com/rails/ActionView/Helpers/UrlHelper/button_to

Comment on lines +5 to +8
resources :tasks do
patch 'mark_incomplete', on: :member
patch 'mark_complete', on: :member
end

Choose a reason for hiding this comment

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

Nice use of resources!

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