Class: Clerk::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/clerk/callback.rb

Instance Method Summary collapse

Instance Method Details

#before_create(record) ⇒ Object



3
4
5
6
# File 'lib/clerk/callback.rb', line 3

def before_create(record)
  record.creator = current_user if record.respond_to?(:creator) && current_user
  record.updater = current_user if record.respond_to?(:updater) && current_user
end

#before_update(record) ⇒ Object



8
9
10
# File 'lib/clerk/callback.rb', line 8

def before_update(record)
  record.updater = current_user if record.respond_to?(:updater) && current_user
end

#current_userObject

relies on ‘include SentientUser` on User



13
14
15
16
17
18
# File 'lib/clerk/callback.rb', line 13

def current_user
  warn "User#current is not defined, are you including SentientUser on your User model?" unless User.respond_to?(:current)
  warn "User#current is nil, are you including SentientController on your ApplicationController?" unless User.current

  User.current
end