Help Your Nanowrimo Effort Resemble an Actual Novel

More than a decade ago a friend gave me a copy of The Marshall Plan for Novel Writing. We had been toying with the idea of writing a novel. A few years later I took some of the ideas we had and applied them during my first nanowrimo. Though the novel soon spiraled out of control (and off script according to the “marshall Plan”,) I felt the structure offered in the book helped me to “win” (writing at least 50,000 words in the month of November.) [Read More]
Tags: Writing

Easily and Quickly Populate Database Tables Using Pure Ruby

When importing data into a database you may want to use your Active Record models to help. Perhaps you want to call your validation rules in your model classes or you just want to put the code in your Rails’ project ‘rake’ tasks. You’d like to use Active Record for the job, but the data outside the database has a lot of records. The problem is that creating each record individually may take too much time. [Read More]

Use Ruby Struct types for mock Active Record objects

You sometimes want to test business logic, possibly outside of Rails, where you don’t want to bother with fixtures and or connecting to a database.  Structs offer a simple solution when you only want to access and modify data in records and associations and aren’t interested in testing finding or saving the data. [Read More]
Tags: Ruby

Rails on Ice

If you want to do fast analysis on very large datasets or you need to extract a small sliver of data from a very wide table or set of tables, check out the free version of the Info-Bright MySql data storage engine.  The non-commercial version is called ICE (InfoBright Community Edition.)  It's intended for data warehouse and archival applications. A crucial point about ICE is that it's read-only.  It doesn't support insert, delete or update.  You can create a schema (with some restrictions,) and you can do any other SQL supported by MySql.  What this means is that to get data into ICE tables you have to use 'load data infile'.  The commercial version doesn't have that restriction. So putting your Rails app on ICE is probably out.  But what if you want to use Rails migrations to generate a schema with ICE or otherwise use Ruby Active-Record to access an ICE database? I downloaded the Linux 64 bit version of ICE from the  InfoBright website and set it up; it was basically a stand-alone version of MySql with the InfoBright storage engine built in.  I was able to connect to it using the standard MySql database adapter, but attempting to re-create a schema from my Migration classes resulted in errors from MySql.  It turns out ICE, because it doesn't support 'insert', doesn't allow primary keys or auto_increment type columns.  In a read-only situation this is okay, but it means your old DDL won't work.  I needed to replace the DDL generated in the 'create_ table' method in migrations with something that ICE would accept.  In every ActiveRecord database adapter class there's a definition of the data types for the database system in question.  MySql looks like [Read More]