Posts tagged as:


I started reading ActiveRecord::Base a few days ago and found 8 things that I didn’t know about that it offered. I also only made it about 1/4 of the way through the code. Here are a few new things I’ve learned upon further reading:

1. Find by multiple ids

Not only can you find a single record by calling find_by_id, you can find multiple records by providing an array of ids.

User.find_by_id([1, 12, 55])
# Returns 3 User objects with ids of 1, 12, and 55. If any isn't found, then RecordNotFound is raised.

2. Locking database records

If you have multiple processes that may update the same record (like incrementing a counter), then you may run into a problem where they both pull the record when the counter = 42. They each update the counter to 43 and save the record. This results in a deviation from reality of 1.

The solution is to lock the record while updating it. Here’s the code: [click to continue…]

{ 1 comment }

A lot of new Ruby developers I’ve worked with have seen the symbol notation—starting with a :— and have been confused by what a symbol actually is. There is a lot of information out there that is confusing as well. Here’s a brief rundown of what symbols are and how they are used.

[click to continue…]


A lot of people try Test Driven Development by writing the test, writing the code, and then wondering what the big deal is. Here’s the process I follow along with an explanation of why each step helps.

As a quick note, all tests are written with the RSpec framework.
[click to continue…]

{ 1 comment }

I’ve had a few discussions with people under various circumstances regarding Test First or Test Driven Development (TDD). Some people swear by TDD, while other don’t see how it could possibly work because “I don’t know how my code works until I write it.” My answer to this is “That’s why you need to write the test first.”

My initial exposure to Test Driven Development was while working for a client at SolutionStream. The client insisted that all development be done Test First. At first, it was a painful process. The tests took a while to write, and I really just wanted to get into solving the problem. As time went on, however, I found that writing the tests first, did a few things that made coding much more pleasant.
[click to continue…]


Setting up a Debug Log

Have you ever been debugging your Rails application and watching the development log fly by wishing that you could put output just the information you need to its own log? There’s actually a quick and easy way to do it.

First, you create your logger.

@debug_log = + "/../../log/debug.log", "w"))

Then you log data to it.

@debug_log.debug @object

It’s simple and it makes the data extremely easy to find. Just take the statements out when you’re done debugging.


During my time as a Quality Assurance Engineer, I would wind up explaining to curious people that what I did was more than just testing software. So, what is Quality Assurance if it’s not just software testing? Quality Assurance is an approach to developing software. It begins with software design and ends with documentation of the product.

Q. A. on Design

Usually there are two parts of the design. You usually have a requirements document and a technical specification. Requirements documents usually have more to do with business needs but can contain flowcharts for different processes involved in the software. Most good Quality Assurance Engineers excel at picking out areas where processes can break down. This skill set doesn’t need to be limited strictly to software processes. If there’s a business process like shipping or communication with clients or other employees, QA Engineers can be useful in making certain that these processes run smoothly by identifying possible problem areas. [click to continue…]

{ 1 comment }