Method: ActionDispatch::Request::Session#merge!

Defined in:
actionpack/lib/action_dispatch/request/session.rb

#merge!Object

Updates the session with given Hash.

session.to_hash
# => {"session_id"=>"e29b9ea315edf98aad94cc78c34cc9b2"}

session.update({ "foo" => "bar" })
# => {"session_id"=>"e29b9ea315edf98aad94cc78c34cc9b2", "foo" => "bar"}

session.to_hash
# => {"session_id"=>"e29b9ea315edf98aad94cc78c34cc9b2", "foo" => "bar"}


191
192
193
194
195
196
197
198
# File 'actionpack/lib/action_dispatch/request/session.rb', line 191

def update(hash)
  unless hash.respond_to?(:to_hash)
    raise TypeError, "no implicit conversion of #{hash.class.name} into Hash"
  end

  load_for_write!
  @delegate.update hash.to_hash.stringify_keys
end