Module: StrongerParameters::ControllerSupport::PermittedParameters::ClassMethods
- Defined in:
- lib/stronger_parameters/controller_support/permitted_parameters.rb
Class Method Summary collapse
Instance Method Summary collapse
- #log_invalid_parameters! ⇒ Object
- #permitted_parameters(action, permitted) ⇒ Object
- #permitted_parameters_for(action) ⇒ Object
Class Method Details
.extended(base) ⇒ Object
36 37 38 |
# File 'lib/stronger_parameters/controller_support/permitted_parameters.rb', line 36 def self.extended(base) base.send :class_attribute, :log_unpermitted_parameters, instance_accessor: false end |
Instance Method Details
#log_invalid_parameters! ⇒ Object
40 41 42 |
# File 'lib/stronger_parameters/controller_support/permitted_parameters.rb', line 40 def log_invalid_parameters! self.log_unpermitted_parameters = true end |
#permitted_parameters(action, permitted) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/stronger_parameters/controller_support/permitted_parameters.rb', line 44 def permitted_parameters(action, permitted) if permit_parameters[action] == :skip || permitted == :skip permit_parameters[action] = permitted else action_permitted = (permit_parameters[action] ||= {}) action_permitted.deep_merge!(permitted) end end |
#permitted_parameters_for(action) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/stronger_parameters/controller_support/permitted_parameters.rb', line 53 def permitted_parameters_for(action) unless (for_action = permit_parameters[action]) # NOTE: there is no easy way to test this, so make sure to test with # a real rails controller if you make changes. = "Action #{action} for #{self} does not have any permitted parameters" += " (#{instance_method(action).source_location.join(":")})" if method_defined?(action) raise(KeyError, ) end return :skip if for_action == :skip # FYI: we should be able to call sugar on the result of deep_merge, but it breaks tests permit_parameters[:all].deep_merge(for_action).transform_values { |v| PermittedParameters.sugar(v) } end |