aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/forbidden_attributes_protection.rb
blob: 39f1a207343c4cce35fe274afe0ed5a97b412a66 (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(new_attributes, options = {})
      if !new_attributes.respond_to?(:permitted?) || (new_attributes.respond_to?(:permitted?) && new_attributes.permitted?)
        super
      else
        raise ActiveModel::ForbiddenAttributes
      end
    end
  end
end