My Blog

Passing on knowledge about software development and related technologies.

Counting Records With ActiveRecord

While counting records with ActiveRecord seems straightforward, you can quickly experience performance problems if not done properly. In the context of Rails ActiveRecord, the methods for counting records each do it a bit differently. Let's take a look at the three methods available in Rails:

  1. count - When called on an ActiveRecord::Relation object, count will perform a SQL COUNT query, which is very fast, especially on large result sets.

  2. size - Like count, size works differently depending on whether you call it on an ... Continue reading


A Password Site That Respects Your Privacy

I like most of you, are constantly having to create new passwords for sites and applications we use daily. Unfortunately, most of the password generator sites cover you with ads or try to collect info on you to sell. Because of this, I decided to write my own and make it respect everyone's privacy.

I used Rails 6 / Ruby 2.7 / JQuery deployed on Heroku to craft this tool. It has simple use analytics (if you create a simple account) and does not collect identifying info on visitors as I use GoatCounter for my analytics on the site. Check it out and feel free to use this tool I ... Continue reading


A URL Shortner That Respects Your Privacy!

My daily work requires me to send or post links fairly regularly and I have always been a fan of URL shorteners. Unfortunately, most of these tools today are nothing but advertising platforms and data collection silos. So, I decided to write my own and make it respect both members' and users' privacy.

I used Rails 6 / Ruby 2.6 with Postgres deployed on Heroku to craft this tool. It has simple use analytics (if you create a simple account) and does not collect identifying info on visitors as I use GoatCounter for my analytics on... Continue reading


Favorite Development Gems Episode 1 - Rails-ERD

This is the first in a series of blog posts on development gems for Rails. I am assuming you know what gems are and their value in the Ruby/Rails ecosystem. If you don't, then here is a link to go check out.

Development gems are used during the development process only and not in production environments. The gems mentioned in this and in the next few posts are my favorites and really help get the work done when developing rails application. Let's get started.

In this first post, I will be focusing on the ... Continue reading


Seeding your database in Rails - Part 2

In the first post about the seeds.rb file we covered the basics of how the seeds.rb file works. In this post, we will be looking at practical examples of how to use the seeds.rb file in a production situation. There are several issues you may have to deal with using the seeds.rb file in a project. First is determining if the data you are about to add to the database already exists. Let's look at how we can do this.

first_or_create and find_or_create_by
There are two methods in Active Record that can be h... Continue reading


Displaying blogs 1 - 5 of 7 in total