What to Do?
Checkov is a simple to-do list app in Rails that allows users to create a to do list which will automatically remove old entries after 7 days. It utilizes Devise for Authentication, AJAX, and custom rake tasks. The project primarily focuses on implementing authentication and AJAX responsiveness to a page.
Tools
Rails, Rspec, jQuery, AJAX, Devise, Faker, whenever, Bootstrap, Atom, Ubuntu
Key Features
Compared to Bloccit, the scope of this project was much more narrow, and largely served to demonstrate the use of vendor gems to expedite common boilerplate functionality, such as user authentication. Devise proved to be quite simple to implement, with built-in functionality for email verification and validation of email and password length and pattern requirements. Likewise I used Faker to seed the database with dummy data for testing. For deleting old tasks, I created a custom cron job using the whenever gem to automatically delete all 7+ day old tasks at 24-hour intervals. Most of these features were fairly easy to deal with, though I encountered some difficulty with getting AJAX going.
The Challenge
Between my lack of knowledge of Javascript and nascent knowledge of using partials, AJAX took some effort to wrap my mind around. I was tasked with using AJAX to for both the creation and destruction of to-do list items. A bit part of the challenge came down to learning to decypher the syntax, as it made heavy use of string interpolation to embed variable names to pass into the appropriate jQuery expressions. To accomplish this, I had to make use of embedded jQuery expressions within a Rails partial to append new list items like so:
Upon submitting the string for a new list item, the partial would be fired to append the list item to the top, then re-render the submission form to clear its contents, with jQuery selectors used to locate and manipulate the appropriate DOM elements.
Delete was a bit trickier:
Here Ruby statements are being interpolated into Javascript to embed new DOM elements, such as the success/fail alert messages and to remove the appropriate item. So long as the tags in the source html file are correct (which they initially were not), only the appropriate item is deleted from the list.
Growth
AJAX was intimidating at first, but as I developed more experience from my subsequent projects I can see more clearly how the pieces fit together. Since this was only my second project, I wasn’t feeling entirely confident in my comprehension of the material. As the routine using embedding, interpolating, and using partials/templates as part of the web app development process became more familiar to me, I find myself more naturally able to understand what I am looking at, even if I am unclear on the exact function of every piece.