Rails modelo de actividad reciente

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

2 Respuestas

Sometime ago I created a gem exactly for this. Source code might come in handy in your case: https://rubygems.org/gems/public_activity

contestado el 07 de mayo de 11 a las 18:05

ActiveRecord handles this situation by providing the ActiveRecord::Base.serialize class method: http://api.rubyonrails.org/classes/ActiveRecord/Base.html#method-c-serialize

Respondido el 09 de enero de 11 a las 00:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.