![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
#<FileHash id: 423, hash: "018cf0b47256973ab6f08a720208c28c34d85722", size: 1393 => @hash.size 1393 => @hash.hash 847 |
#2
| |||
| |||
|
|
Hi all, I've got a c++ program that inserts data into a mysql database, its a 32 length varchar column in question that contains sha256 hashes such as 018cf0b47256973ab6f08a720208c28c34d85722 Unfortunately, when I come to read this in rails and print out the hash in a view, it prints out a short integer like 847. I've tried it in irb, I can see the hash correctly as the return value of a .find, but it still comes out wrong when I print it directly: => @hash = FileHash.find(:first) #<FileHash id: 423, hash: "018cf0b47256973ab6f08a720208c28c34d85722", size: 1393 => @hash.size 1393 => @hash.hash 847 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. Hope someone can shed light on this. Thanks Matt |

#3
| |||
| |||
|
|
On Sat, Nov 07, 2009 at 12:06:07AM +0000, Matt Harrison wrote: Hi all, I've got a c++ program that inserts data into a mysql database, its a 32 length varchar column in question that contains sha256 hashes such as 018cf0b47256973ab6f08a720208c28c34d85722 Unfortunately, when I come to read this in rails and print out the hash in a view, it prints out a short integer like 847. I've tried it in irb, I can see the hash correctly as the return value of a .find, but it still comes out wrong when I print it directly: => @hash = FileHash.find(:first) #<FileHash id: 423, hash: "018cf0b47256973ab6f08a720208c28c34d85722", size: 1393 => @hash.size 1393 => @hash.hash 847 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. Hope someone can shed light on this. Thanks Matt Well to answer my own question yet again: 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 ![]() Matt |
#4
| |||
| |||
|
|
On Sat, Nov 07, 2009 at 12:06:07AM +0000, Matt Harrison wrote: 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 ![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |