Created
October 20, 2012 14:47
-
-
Save kcurtin/3923466 to your computer and use it in GitHub Desktop.
Marshalling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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