0

Is there a way to convert JSON objects into Rails? What I'm trying to do is converting many Rails (Active Record) Objects into JSON, so I can take them into the session cookies and use them when the user needs the information. If you've got any better idea don't mind to say it.

Diego
  • 63
  • 1
  • 5
  • This should interest you: http://stackoverflow.com/questions/4464050/ruby-objects-and-json-serialization-without-rails – vee Jan 07 '14 at 03:09
  • You do know that cookies are limited to 4kb, right? And that storing sensitive information in a cookie is undesirable? – sethvargo Jan 07 '14 at 03:34

1 Answers1

0

Rails has a to_json method which you can use.

e.g

User.first.to_json

will return

"{\"id\":1,\"username\":\"test_user\"}
juanpaolo
  • 625
  • 5
  • 14