RailsCasts Pro episodes are now free!

Learn more or hide this

Dangers of Model in Session

#13 Dangers of Model in Session

Apr 02, 2007 | 5 minutes | Controllers
Be careful when storing a model in a session. It will behave differently than you expect and can easily get out of sync with the database. Instead of storing the model directly in the session, store the id to the model and use that to fetch it from the database.
  • Download:
  • mp4Full Size H.264 Video (7.46 MB)
  • m4vSmaller H.264 Video (5.27 MB)
  • webmFull Size VP8 Video (14.9 MB)
  • ogvFull Size Theora Video (13.7 MB)