mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Minor refactoring to prettify
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@517 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
ac8ebc19be
commit
838c5a3d82
1 changed files with 3 additions and 8 deletions
|
@ -29,12 +29,8 @@ class CGI
|
|||
#
|
||||
# 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 @@ class CGI
|
|||
# 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
|
||||
|
|
Loading…
Reference in a new issue