Rails 3 - How to Create a JSON Object to store in the database

Viewed 37126

I'm creating an AuditLog observer that watches over several models.

I'd like the observer to have an after_create, which creates a JSON object that is stored in a database column. It will contain data like {photoid:123, photoname: "asdasd", creator_id: "asdasd"} etc...

In Rails, how do I create this type of JSON object and then how do I insert it into the DB along with other non-JSON fields?

Thanks

3 Answers
Related