authorize! :create_from_checklist, Task # resource_params comes from our private API interactor = ChecklistTasksFactory.new(checklist_params, resource_params, current_user) result = interactor.call if result.successful? # result.tasks will raise NoMethodError as tasks is not exposed by the interactor render json: TaskMapper.all_as_json(result.tasks, scope: current_user) else # Interactor::Result exposes #errors by default render_errors(result.errors) end end private def checklist_params params.require(:task).permit(checklist: [:id]) end end