Most Common Types of Technical Debt in Rails

Introduction

The majority of the Rails custom software development work we do here at NextLink Labs deals with rehabilitating older projects that are overwhelmed with technical debt from years of development without refactoring.

The software problems in these websites are never introduced maliciously. Instead, these problems tend to build up gradually over months and years after many rushed deadlines, strict client demands that don't allow for refactoring, and inexperienced Rails developers trying their best but getting overwhelmed by "Rails magic."

Pushing Rails Validations Down to The Database?

Ever open up a Rails console to debug a problem and come away wondering how the data got so funky? Despite our best efforts, the database will accept plenty of garbage data if you let it. There are tons of methods to bypass the Rails callbacks and validations while still updating your database. If you are like me you have probably used these methods in the Rails console to fix some of that funky data you found after some other code created it in the first place.

Active Record Validations are a good place to start to prevent the funk. They will check the attributes for presence, absence, numericality, length, inclusion, format, exclusion, acceptance, and more. You can validate your model’s data easily and prevent any number of common errors this way. They aren’t the end of the problem but for most funky data you see your mind should go to checking the validations and probably writing another one. 

Best Ruby Practices Beginners Should Know

Python’s dominance is never really questioned when it comes to the best for programming novices because it checks almost every box that defines a simple language. It’s remarkably easy to pick up and can rise to any challenge. But what about Ruby?

Although it does not get enough credit for being one, Ruby is an awesome language for beginners. It provides powerful constructs (like blocks) and versatile concepts (like message passing à la Smalltalk) but retains Python’s fluid and elegant English-like syntax. In fact, in many cases, one might argue that the unique design choices that went into the Ruby syntax beat even Python in terms of readability and expressiveness. If you’re getting into programming, it’s very easy to recommend that you start with Ruby.

Connect to Cloudant Data in Ruby

The CData ODBC Driver for Cloudant makes it easy to integrate connectivity to live Cloudant data in Ruby. This article shows how to create a simple Ruby app that connects to Cloudant data, executes a query, and displays the results.

Create an ODBC Connection to Cloudant Data

If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs.