Permalink
Browse files

Minor refactoring to prettify

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@517 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent ac8ebc1 commit 838c5a3d82367977d13ced01f9e28c22ccff32ef @dhh dhh committed Feb 6, 2005
Showing with 3 additions and 8 deletions.
  1. +3 −8 actionpack/lib/action_controller/session/active_record_store.rb
@@ -29,12 +29,8 @@ class Session < ActiveRecord::Base
#
# This session's ActiveRecord database row will be created if it does not exist, or opened if it does.
def initialize(session, option=nil)
- @session = Session.find_first(["sessid = '%s'", session.session_id])
- if @session
- @data = @session.data
- else
- @session = Session.new("sessid" => session.session_id, "data" => {})
- end
+ @session = Session.find_by_sessid(session.session_id) || Session.new("sessid" => session.session_id, "data" => {})
+ @data = @session.data
end
# Update and close the session's ActiveRecord object.
@@ -60,8 +56,7 @@ def restore
# Save session state in the session's ActiveRecord object.
def update
return unless @session
- @session.data = @data
- @session.save
+ @session.update_attribute "data", @data
end
end #ActiveRecordStore
end #Session

0 comments on commit 838c5a3

Please sign in to comment.