aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/forbidden_attributes_protection.rb
blob: 29bc47f15182b6ec36ef1d695949c28fee5e45c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
module ActiveModel
  class ForbiddenAttributes < StandardError
  end

  module ForbiddenAttributesProtection
    def sanitize_for_mass_assignment(attributes, options = {})
      if attributes.respond_to?(:permitted?) && !attributes.permitted?
        raise ActiveModel::ForbiddenAttributes
      else
        attributes
      end
    end
  end
end