I have a rails model called "ActivityStream" in this model I have these members account_id :integer project_id :integer activity_type :string data :binary
in the data field I want to store an object (model) so that I can show the activity to the user.
I have an observer on the project class, where I do this: http://pastie.org/1440976
The problem is that what is being saved to the database is only the ID of the record or I get an exception on the gsub method (I am using sqlite3 in development)
My question is: What can I do to store the model inside the data column so that I can then retrieve it with ease.
B.T.W I am using rails 3
preguntado el 08 de enero de 11 a las 21:01
ActiveRecord handles this situation by providing the ActiveRecord::Base.serialize class method: http://api.rubyonrails.org/classes/ActiveRecord/Base.html#method-c-serialize