I can't think what would be causing this, I've never come across anything
quite like this before. I'm not using any unusual encodings or anything, at
least, I'm using the same a I always have without problems.
It turns out that hash is a method defined by activerecord already. I
originally had problems naming my model Hash so I changed it to FileHash. I
didn't realise that hash was a method as well as a class.
Changing the column name in the db, rails and the c++ app has fixed the
problem