Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class YourModel < ActiveRecord::Base
- require 'json'
- def your_serialized_attribute=(hash)
- self[:your_serialized_attribute] = hash.to_json # This is actually what's going in to the database
- end
- def your_serialized_attribute
- @serialized_attribute ||= JSON.parse(self[:your_serialized_attribute])
- end
- end
Add Comment
Please, Sign In to add comment