Closed kapso closed 3 years ago
Generally you'd skip permitting the params and send them through to the interaction which will filter them. There's no way around using the filters and @_interaction_raw_inputs
is an internal variable subject to change without notice in the CHANGELOG.
@AaronLasseigne thanks for the quick response, and your work on this gem.
So I tried passing params
from Rails controller, and run into the following...
to_h': unable to convert unpermitted parameters to hash (ActionController::UnfilteredParameters)
I am guessing this issue is still in TBD state judging from this thread - https://github.com/AaronLasseigne/active_interaction/issues/381
Or perhaps to_unsafe_h
is the way to go?
Unfortunately, we cannot disable strong parameters for the app, coz we are only using active_interaction
for some of the controller actions for now.
You can pass them through directly:
SomeInteraction.run(params)
I made it this way to "skip" the filters:
# controller
Interaction.run(params.merge(raw_params: params))
# interaction
class YourInteraction
hash :raw_params, strip: false
def execute
raw_params
end
end
I want to pass a hash to an interaction that is a nested hash, and it's already filtered in a Rails controller using
params.permit(:key1, key2, { country_codes: [], expense: [:min, :max] })
, so I would hate to filter it again in my interaction.So something like this...
Search.run(params: query_params)
orSearch.run(query_params)
Is something like this possible? i.e, not using filters and yet the contents of the hash are available.
I realized I can access the raw input using
@_interaction_raw_inputs
which will solve my issue but is there a cleaner approach to this?