Feature(s) impacted
Smart action on related data
Observed behavior
When using ForestLiana::ResourcesGetter.get_ids_from_request(params, forest_user)
(like explained in the documentation) in smart actions, it would throw an error if:
- the smart action is executed from related data in a collection
- the smart action is executed on all documents
E.g:
def my_custom_action
ids = ForestLiana::ResourcesGetter.get_ids_from_request(params, forest_user)
=> eval error: undefined method `to_sym' for nil
/gems/ruby/3.3.0/gems/forest_liana-9.4.1/app/services/forest_liana/has_many_getter.rb:69:in `model_association'
/gems/ruby/3.3.0/gems/forest_liana-9.4.1/app/services/forest_liana/has_many_getter.rb:11:in `initialize'
/gems/ruby/3.3.0/gems/forest_liana-9.4.1/app/services/forest_liana/resources_getter.rb:156:in `new'
/gems/ruby/3.3.0/gems/forest_liana-9.4.1/app/services/forest_liana/resources_getter.rb:156:in `initialize_resources_getter'
/gems/ruby/3.3.0/gems/forest_liana-9.4.1/app/services/forest_liana/resources_getter.rb:26:in `get_ids_from_request'
(rdbg)//usr/src/app/app/controllers/forest/financial_transaction_actions_controller.rb:1:in `match_without_document'
end
For now, I have managed to mitigate this behavior with the following (ugly) workaround:
def my_custom_action
attributes = params.dig(:data, :attributes)
attributes[:association_name] = attributes[:parent_association_name] = "financial_transactions"
attributes[:id] = attributes[:parent_collection_id]
ids = ForestLiana::ResourcesGetter.get_ids_from_request(params, forest_user)
# ...
end
!!! Note: this workaround does not work on smart relationships.
Expected behavior
The helper would return the list of impacted ids.
Context
- Project name: Finance X
- Team name: Operations
- Environment name: Development
- Agent technology: rails
- Agent (forest package) name & version: forest_liana (9.3.16)
- Database type: postgresql