diff --git a/app/datatables/protocol_linked_children_datatable.rb b/app/datatables/protocol_linked_children_datatable.rb index 0963befda..8b913102f 100644 --- a/app/datatables/protocol_linked_children_datatable.rb +++ b/app/datatables/protocol_linked_children_datatable.rb @@ -86,10 +86,7 @@ class ProtocolLinkedChildrenDatatable < CustomDatatable def filter_child_records(records) if params[:version].present? - version = params[:version] - records = records.joins('LEFT JOIN protocols protocol_parents ' \ - 'ON protocols.parent_id = protocol_parents.id ') - .where('protocol_parents.version_number = #{version}') + records = records.left_outer_joins(:parent).where(parent: { version_number: params[:version] }) end records end