37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/auditing/audit_relationship.rb', line 37
def gather_assoc_fields_for_auditing(fields=nil)
poly_array = []
reflect_on_all_associations(:belongs_to).each do |assoc|
poly_array << assoc.name if assoc.options[:polymorphic]
end
unless fields
if poly_array.nil?
return default_columns
else
tmp_names = default_columns
poly_array.each do |poly|
tmp_names = tmp_names.reject {|column| column.match(/#{poly.to_s}*/)}
end
end
return tmp_names
else
fields.is_a?(Array) ? fields.map {|f| f.to_s} : [fields.to_s]
end
end
|