Skip to content

Instantly share code, notes, and snippets.

@kcurtin
Created October 20, 2012 14:47
Show Gist options
  • Save kcurtin/3923466 to your computer and use it in GitHub Desktop.
Save kcurtin/3923466 to your computer and use it in GitHub Desktop.
Marshalling
def self.save_record(student)
record = Marshal.dump(student)
db_connection.execute('INSERT INTO students (student) VALUES (?);', [record])
end
def self.update_record(student)
id = student.id
row = Marshal.dump(student)
db_connection.execute('UPDATE students SET student = ? WHERE id = ?', [row, id])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment