class MySession < ActiveRecord::Base has_many ... belongs_to ... validates...
class < self def current Thread.current[:session] end def current=(s) Thread.current[:seesion] = s end end
# instance methods def ... end end
class ApplicationController < ActionController::Base before_filter :setup_my_session
private def setup_my_session MySession.current = session[:my_session_id] end end
helllo.rhtml <%= "Hello #{MySession.current.user.name}! %>
This is an extreme example but it follows the principle of storing object ids in the session and objects the database. You get all the benefits of ActiveRecord without the downsides of managing complicated session data.
Aaron