lib/cancan/ability/strong_parameter_support.rb
# Returns an array of attributes suitable for use with strong parameters
#
# Note: reversing the relevant rules is important. Normal order means that 'cannot'
# rules will come before 'can' rules. However, you can't remove attributes before
# they are added. The 'reverse' is so that attributes will be added before the
# 'cannot' rules remove them.
Returns an array of attributes suitable for use with strong parameters
Note: reversing the relevant rules is important. Normal order means that 'cannot'
rules will come before 'can' rules. However, you can't remove attributes before
they are added. The 'reverse' is so that attributes will be added before the
'cannot' rules remove them.
Returns an array of attributes suitable for use with strong parameters Note : reversing the relevant rules is important . Normal order means that ' cannot ' rules will come before ' can ' rules . However you can ' t remove attributes before they are added . The ' reverse ' is so that attributes will be added before the ' cannot ' rules remove them .
def permitted_attributes(action, subject)
        relevant_rules(action, subject)
          .reverse
          .select { |rule| rule.matches_conditions? action, subject }
          .each_with_object(Set.new) do |rule, set|
          attributes = get_attributes(rule, subject)
          rule.base_behavior ? set.merge(attributes) : set.subtract(attributes)
        end.to_a
      end
def permitted_attributes ( action , subject ) relevant_rules ( action , subject ) . reverse . select { | rule | rule . matches_conditions? action , subject } . each_with_object ( Set . new ) do | rule , set | attributes = get_attributes ( rule , subject ) rule . base_behavior ? set . merge ( attributes ) : set . subtract ( attributes ) end . to_a end
Returns an array of attributes suitable for use with strong parameters
Note: reversing the relevant rules is important.
Returns an array of attributes suitable for use with strong parameters Note : reversing the relevant rules is important .
# add attributes for 'can', remove them for 'cannot'
action
<not_specific>
subject
<not_specific>