Skip to content

Commit ea93dc5

Browse files
committed
Merge pull request #166 from tovodeverett/avoid_current_user_call
Avoid call to current_user in AuthorizationInController#permitted_to* when :user option is passed.
2 parents ad0a6a8 + a051d11 commit ea93dc5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/declarative_authorization/in_controller.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,12 @@ def options_for_permit (object_or_sym = nil, options = {}, bang = true)
176176
object = object_or_sym
177177
end
178178

179-
{:user => current_user,
180-
:object => object,
179+
result = {:object => object,
181180
:context => context,
182181
:skip_attribute_test => object.nil?,
183182
:bang => bang}.merge(options)
183+
result[:user] = current_user unless result.key?(:user)
184+
result
184185
end
185186

186187
module ClassMethods

0 commit comments

Comments
 (0)