I first used Ruby at a previous workplace when I built a small app with Sinatra to control test accounts. I really enjoyed the simplicity of Ruby and the amount of Gems available. As a natural extension, I wanted to dabble with a full-featured framework so I began learning Ruby on Rails. Michael Hartl’s Ruby on Rails tutorial proved very helpful to learn the basics.
As a first project, I wanted to build something simple yet had a good set of features . At the same previous workplace, we had many mobile devices and laptops for testing and it was always a challenge to track who had which device, and to keep track of the devices in our inventory along with their details. I searched for such tools but couldn’t find anything that was free and easy to use/setup. This is a perfect first project and solves a problem others may have. While I did have an Intern develop this same tool at the time, I wanted to start from scratch and build everything on my own, with the help of Michael Hartl’s tutorial.
At this point, I need to say something about Ruby on Rails because I can feel the disapproval of some developers looming over my head as I type this. Here goes, I truly think RoR is a great framework. Yes it prescribes a specific way of doing things, but I don’t believe that’s bad. It makes your code predictable, shareable, and organized. Can it backfire? Of course! But it’s up to the developer, just like any other framework. Is scalability and speed an issue? Potentially, but I’m not building the next Twitter here. In the end, as a person more heavily diving into web development, you can’t argue with how easy it is to get up and running. Having said that, I do plan on building the same app with one of Angular/Vue/React for learning purposes.
Now, on to the fun stuff. Here are the features I incorporated:
- Add/edit/delete users (admin and non-admin capabilities)
- Login functionality
- Add/edit/delete devices
- Ability to check-in/check-out a device
- History tracking for check-in/check-out on a per user and per device level
I used Bootstrap out of the box as I wasn’t worried about a unique design (although still had to look presentable). While I did also incorporate MailGun for sending email, I scrapped the idea because I didn’t want a potentially paid service attached to the app.
I started by building the the User controller, model, and views. I then added sessions to manage logins and the “remember me” feature. Next came the basics of the Device controller, model, and views. To connect users and devices, I opted to use a has-many-through relationship with a Checkouts model. This is because a user could have many devices checked out and a device could be checked out by many users (not at the same time though). Finally, I built the history functionality by surfacing the details of the Checkouts model.
I will say I probably did many things wrong, and I felt something was off in some cases, but it’s good enough for a first try in my opinion. Anyways, here are some screenshots of the app:
I had two goals for this project, to create a tool that could be useful for someone facing the challenge of managing devices, and to learn Ruby on Rails. It was definitely a good learning experience and I enjoyed the process. You can find the tool and code on my GitHub account here.