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

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