module ActiveScaffold::ActiveRecordPermissions::ModelUserAccess::Controller

Public Class Methods

included(base) click to toggle source
# File lib/active_scaffold/active_record_permissions.rb, line 32
def self.included(base)
  base.prepend_before_action :assign_current_user_to_models
end

Public Instance Methods

assign_current_user_to_models() click to toggle source

We need to give the ActiveRecord classes a handle to the current user. We don’t want to just pass the object, because the object may change (someone may log in or out). So we give ActiveRecord a proc that ties to the current_user_method on this ApplicationController.

# File lib/active_scaffold/active_record_permissions.rb, line 39
def assign_current_user_to_models
  ActiveScaffold::Registry.current_user_proc = proc { send(ActiveRecordPermissions.current_user_method) }
end