Skip to content

Commit

Permalink
Fix Rbac#apply_select extra_cols logic
Browse files Browse the repository at this point in the history
Fixes and issue with Rbac#apply_select when `:extra_cols` exists and an
already existing `.select` is in the scope.  Currently, this will throw
an error (I guess).
  • Loading branch information
NickLaMuro committed Jan 15, 2019
1 parent 6d1c45d commit ca775c1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rbac/filterer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,9 @@ def apply_scope(klass, scope)
end

def apply_select(klass, scope, extra_cols)
scope.select(scope.select_values.blank? ? klass.arel_table[Arel.star] : nil).select(extra_cols)
scope = scope.select(klass.arel_table[Arel.star]) if scope.select_values.blank?
scope = scope.select(extra_cols) if extra_cols.present?
scope
end

def get_belongsto_matches(blist, klass)
Expand Down

0 comments on commit ca775c1

Please sign in to comment.