views:

131

answers:

1

This is what I tried

f = 1.2
f = Marshal.dump(f) #\004\bf\v1.2\00033

after that I tried to save this f into text column and this is an error I got.

ActiveRecord::StatementInvalid: SQLException: unrecognized token: "fϾ1.2 33" (Ͼ is male symbol, but I can't find one).
A: 

i use a simple wrapper in my model that dumps the data and encodes it base64 so that it is a raw string:

def data=(data)
  write_attribute :data, ActiveSupport::Base64.encode64(Marshal.dump(data))
end

def data
  Marshal.load(ActiveSupport::Base64.decode64(read_attribute :data))
end
phoet