Rails ActiveRecord object not saving
I have this table that stores serialized objects:
class CachedObject < ActiveRecord::Base
attr_accessible :key, :data
validates_uniqueness_of :key
end
The data column stores a serialized object indexed by key. Pretty simple.
I'm running this code to test:
key = "test"
obj = {"test" => "test"}
row = CachedObject.find_or_create_by_key key
row.data = obj.to_json
row.save
The object is getting created, but it's not saving back to the database.
No error messages. What am I doing wrong here?
No comments:
Post a Comment