Method: Volt.as_user

Defined in:
lib/volt/volt/users.rb

.as_user(user_id) ⇒ Object

as_user lets you run a block as another user

Parameters:

  • user_id (Integer)


39
40
41
42
43
44
45
46
# File 'lib/volt/volt/users.rb', line 39

def as_user(user_id)
  previous_id = Thread.current['with_user_id']
  Thread.current['with_user_id'] = user_id

  yield

  Thread.current['with_user_id'] = previous_id
end