On the 20ᵗʰ of October, after two weeks of #EndSARS protests, the Nigerian Military opened fire on peaceful protesters all over Nigeria. Nigerians on the ground streamed live to Instagram, most famously DJ Switch, and we saw protesters running for cover, falling to the ground, and holding on their breaths as those around them tried to save their lives. It was a traumatic day for Nigerians everywhere.
In the aftermath, Nigerians expressed a desire to up-skill and create a world for themselves where such a thing couldn’t happen. There has been talk of creating resources that teach the real history of Nigeria, or that explain how voting works and gives information about the real political landscape of the country. There were also those, like Ernest Ojeh who wanted to mentor those who wanted it and help them get jobs, more technologists joined in and after speaking to my manager we thought it’d be a good idea to create a directory where Nigerians could freely search for tech mentors. So I did.
Starting out in Node
This was supposed to be a quick project, a basic CRUD app with authentication for one model and filtering. I initially didn’t put much thought into the tech, I chose Node & Express.js, despite being a Ruby engineer, because my team uses Node, and that was it. I’ve used Node briefly in the past and for my last project so I understand how it works however, I quickly realised it probably wasn’t the best choice for me in this case. What I quickly found is that Node takes single responsibility very seriously and is very modular, and doesn’t really allow you to build your modules up as you’re creating the app. For example, when initialising a new project, there’s no way to also specify what database you want to use or if you want a test suite. This isn’t a bad thing though, it’s just a thing which is great in some instances and an inconvenience in others. Having to look for packages that would do every little thing I needed my app to do (e.g. authenticate, handle emails, etc) took up valuable time that I could have spent building.
Moving to Rails
After 2 days pouring over docs and the ok from my manager, I moved to Rails. Within 3mins (literally, I timed it) I had a rails project with a test and development database, a model with authentication and emails.
When I create a new project from the command line with
rails new I can also pass through a number of flags to tweak my project just right:
rails new <app> -T -d=postgresql -C —-skip-action-text
In this line I’m defining my rails project, skipping tests, defining the database, and skipping ActionCable (Rails’ websockets interface) and ActionText (Rails’ WSYWIG editor). Many people have complained that Rails comes with too much stuff out of the box, but having the choice what modules to include in your project on initialisation makes all the difference. By default, Rails comes with ActionMailer which handles creating and sending emails from within the application, so I just have to concern myself with creating the emails and sending them when I need to.
For authentication, Rails has a basic solution in
has_secure_password, which is dependent on the
bcrypt gem. This gem is included in the Gemfile (the equivalent of a package.json) when the app is created but is commented out so you don’t have to use it unless you want to. I chose a different route by using Devise. This gave me more features and a user-flow out of the box, which is what I needed for this project. With Devise I just need to say which model I want to add authentication too and the gem handles the rest, it comes with fully customisable forms and handles confirmation and password reset emails.
With Rails I was able to get a working app with all the key features, and happy path, in less than 2 days. I spent the rest of the time ensuring that errors were properly displayed, things looked good & the deployed app worked as intended.
Rails is often condemned for having too much stuff and it’s true, it does come with a lot, the magic (which is really just abstraction) of Rails can be a hinderance in some cases, but when you need a working app quickly, Rails is great. If you don’t need to spend so much time thinking about the tools, Rails is fantastic for giving you all of them but also not forcing you to use them.
This project isn’t a fix to the problem of police brutality in Nigeria, neither does it directly address it, the Nigerian government needs to #EndSARS (in all it’s permutations) and hold those responsible for the massacres that took place on 20/10/20, accountable.