We are going to build a Task List in Rails. This web application will enable us to keep track of list of tasks with the functionality to add, edit and remove tasks from a list.
Tracking tasks in a web app will let us focus on following Rails conventions and learning how data flows through a Rails application.
Once you've achieved this baseline, take a walk around the room and see if you can answer questions or help other folks.
- Start with our standard Github setup (fork this repo and clone to your machine)
- Create a Rails application
- Create a controller for your
Tasks
- Conform to Rails conventions on naming and inflection
- Create a controller for your
- Create a
Task
model and migration.- Create the database schema and tables with
rake db:migrate
- The
Task
model should include at least the keys indicated below
- Create the database schema and tables with
Tinker with your Model in the rails console
in order to ensure you have created your model and can interact with it as expected.
Each task record will include all of the following. Optional in this context means that the user may choose not to provide this information, but it is still required for your schema:
- Self-incrementing identifier (ID)
- title: the title of the task
- description: details about the task
- completed_at: the time and date the task was completed
This wave is where we will introduce the view layer to interact with our application via the browser.
- Set up necessary controller(s) and route(s) that you will need in order to show a task from the database
- Create a root route for your application that directs users to the list of all tasks
- Each task name in the list should link to a
show
action that will render a new view for the user. - The
show
view should include the complete information about the task: name, description, completion status, and completion date/time.
- Each task name in the list should link to a
- All markup in all views should have semantic relevance.
In this wave we will add the first set of user interactivity and persistence.
- Be able to create a new task:
- The home page should contain a link to Add a new task. This will give the user a form to fill out with the appropriate task fields.
- After the new task is added, the site should take the user back to the home page which displays the full list of tasks. The new task that was just added should be included in the full list of tasks.
- Be able to delete an existing task:
- Add a route and controller action whose responsibility is deleting a task (RESTful routes)
- On the home page, add a button or link for each task that will, once clicked...
- Ask the user to confirm that they definitely want to delete the task.
- Delete the task from the database and redirect the user back to the list of remaining tasks.
In this wave we will extend the interactivity with users, allowing them to edit existing tasks in a couple of different ways. As always, follow RESTful conventions when implementing these features.
- Add the ability for the user to mark a task complete
- Add a button to the list of tasks on the home page that, when clicked, will mark a task complete.
- Update the database with the task's completed date
- Add the ability for the user to edit a task's details.
- Add an
edit
action that renders a form allowing the user to update all the fields of a task. - Submitting the form from the
edit
action should update the existing task; not create a new one.- Research: ActiveRecord's
update
method.
- Research: ActiveRecord's
- Link to the
edit
action from the task'sshow
page. - Optional: DRY up your code by reusing the view code from the
new
functionality- Hint: Rendering partials in Rails.
- Add an