Member-only story

Jacob Lozano
3 min readJul 27, 2020

Often times QoL fixes change code that make 90% of the tasks we do 10% faster, but make the other 10% of tasks 100% slower. It can be a pain when your entire program is in the 10% niche.

Ruby, and by extension Rails, ActiveRecord, and all other libraries/gems that are built upon Ruby, can deal with issues of pluralization. Before QoL improvements, you would have to specifically create tables for your multiple instances. And since Ruby is founded upon readability, you want to make sure that your tables reflected this plurality by making the octopus instances in your table octopi .

Or is it octopuses? Well, the beauty of library independence is that you and your team can determine the pluralization that you want. But what if a library does the work for you? What if your lead dev is a stickler for prescriptive language and doesn’t much care for octopi and says octopuses is obviously the correct table name. Well now you have some workaround to do. There are a few ways to deal with this issue, ranging from changing the actual pluralize method to simply naming the table yourself and pointing Ruby to it, avoiding the QoL functions completely.

The first and most simple option is to utilize the :class_name option. There are quite a few options, as well as default arguments that you can edit to tailor your association. In the case of :class_name, you can explicitly declare the child class:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

No responses yet

Write a response