Deleting a Rails Active Records Object with AJAX & Vanilla JS
One of my commitments for this year is to learn more JavaScript, including: a) as a language, fundamentally, b) as a framework (i.e. VueJS), and c) as a part of Ruby on Rails.
I always knew I was good at juggling.
In regards to point (c), the upside of learning Ruby on Rails is that you don’t need a deep understanding of JavaScript (or even Ruby, for that matter) to get up and running. It’s entirely possible to spend months and months focused exclusively on practicing and writing good, clean Rails code. The downside, of course, is that you can end up with a knowledge of JS that doesn’t extend far beyond the basics.
And by you, I mean me.
Having decided that that needed to change, I wanted to start simple: deleting a Rails Active Record object using AJAX and vanilla JavaScript. In this particular case, my aim was to delete an instance of a Contact, which belongs to an Episode. I made it a particular point not to use jQuery, as everything jQuery does can be done with vanilla Javascript, and without the weight.