thoughtbot/shoulda-matchers · error · ActionNotDefinedError
You must specify the controller action using the #for method
Error message
You must specify the controller action using the #for method.
What it means
Error "You must specify the controller action using the #for method." thrown in thoughtbot/shoulda-matchers.
Source
Thrown at lib/shoulda/matchers/action_controller/permit_matcher.rb:321
def actual_permitted_parameter_names
@_actual_permitted_parameter_names ||= begin
options =
if subparameter_name
{ for: subparameter_name }
else
{}
end
parameters_double_registry.permitted_parameter_names(options)
end
end
def unpermitted_parameter_names
expected_permitted_parameter_names - actual_permitted_parameter_names
end
def ensure_action_and_verb_present!
if action.blank?
raise ActionNotDefinedError
end
if verb.blank?
raise VerbNotDefinedError
end
end
def default_verb
case action
when :create then :post
when :update then RailsShim.verb_for_update
end
end
def parameter_names_as_sentence
expected_permitted_parameter_names.map(&:inspect).to_sentence
end
View on GitHub (pinned to 79cdfbc326)
When it happens
Trigger: Thrown at lib/shoulda/matchers/action_controller/permit_matcher.rb:321 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of thoughtbot/shoulda-matchers@79cdfbc326 (2026-08-23).
Data as JSON: /api/errors/a42e90a6634011c8.
Report an issue: GitHub.