Module: ActiveRecordPermissions::ModelUserAccess::Controller

Defined in:
lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_record_permissions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



36
37
38
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_record_permissions.rb', line 36

def self.included(base)
  base.prepend_before_filter :assign_current_user_to_models
end

Instance Method Details

#assign_current_user_to_modelsObject

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.



43
44
45
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_record_permissions.rb', line 43

def assign_current_user_to_models
  ActiveRecord::Base.current_user_proc = proc {send(ActiveRecordPermissions.current_user_method)}
end