and this is something that came in picture
`dump': no marshal_dump is defined for class Mysql (TypeError
and this is a small code snippet which will give you this situation
require "rubygems"
require "mysql"
class RandomClass
def initialize
@db_instance = Mysql.real_connect("hostname", "username", "password", "database_name")
end
end
random_class = RandomClass.new
a = Marshal.dump(random_class)
and there you are, so one can't serialize a object with MySql object in it and with the set of finding i can even say that serializing even with yaml is also not possible.
So work around to this that i can suggest is to do a close of live mysql object in the method itself so that at any give time when object will be passed to serialization using Marshal.dump there would be no live MySql object to hinder with serialization :)
try this piece of snippet now
require "rubygems"
require "mysql"
class RandomClass
def initialize
db_instance = Mysql.real_connect("hostname", "username", "password", "database_name")
db_instance.close
end
end
random_class = RandomClass.new
a = Marshal.dump(random_class)
And this should work :)