Exception: ActionController::ParameterMissing
- Inherits:
-
KeyError
- Object
- KeyError
- ActionController::ParameterMissing
- Includes:
- DidYouMean::Correctable
- Defined in:
- lib/action_controller/metal/strong_parameters.rb
Overview
Raised when a required parameter is missing.
params = ActionController::Parameters.new(a: {})
params.fetch(:b)
# => ActionController::ParameterMissing: param is missing or the value is empty or invalid: b
params.require(:a)
# => ActionController::ParameterMissing: param is missing or the value is empty or invalid: a
params.expect(a: [])
# => ActionController::ParameterMissing: param is missing or the value is empty or invalid: a
Direct Known Subclasses
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
:nodoc:.
-
#param ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#corrections ⇒ Object
:nodoc:.
-
#initialize(param, keys = nil) ⇒ ParameterMissing
constructor
:nodoc:.
Constructor Details
#initialize(param, keys = nil) ⇒ ParameterMissing
:nodoc:
28 29 30 31 32 |
# File 'lib/action_controller/metal/strong_parameters.rb', line 28 def initialize(param, keys = nil) # :nodoc: @param = param @keys = keys super("param is missing or the value is empty or invalid: #{param}") end |
Instance Attribute Details
#keys ⇒ Object (readonly)
:nodoc:
26 27 28 |
# File 'lib/action_controller/metal/strong_parameters.rb', line 26 def keys @keys end |
#param ⇒ Object (readonly)
:nodoc:
26 27 28 |
# File 'lib/action_controller/metal/strong_parameters.rb', line 26 def param @param end |
Instance Method Details
#corrections ⇒ Object
:nodoc:
37 38 39 |
# File 'lib/action_controller/metal/strong_parameters.rb', line 37 def corrections # :nodoc: @corrections ||= DidYouMean::SpellChecker.new(dictionary: keys).correct(param.to_s) end |