Class: ActiveRecord::Associations::AssociationCollection
- Inherits:
-
AssociationProxy
- Object
- AssociationProxy
- ActiveRecord::Associations::AssociationCollection
- Defined in:
- lib/active_record/connection_adapters/ibm_db_pstmt.rb
Overview
End of class HasManyAssociation
Direct Known Subclasses
Instance Method Summary collapse
Methods inherited from AssociationProxy
Instance Method Details
#find(*args) ⇒ Object
1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 |
# File 'lib/active_record/connection_adapters/ibm_db_pstmt.rb', line 1430 def find(*args) = args. param_array = [] # If using a custom finder_sql, scan the entire collection. if @reflection.[:finder_sql] expects_array = args.first.kind_of?(Array) ids = args.flatten.compact.uniq.map { |arg| arg.to_i } if ids.size == 1 id = ids.first record = load_target.detect { |r| id == r.id } expects_array ? [ record ] : record else load_target.select { |r| ids.include?(r.id) } end else conditions = "#{@finder_sql}" param_array = param_array + @finder_sql_param_array unless @finder_sql_param_array.nil? if sanitized_conditions = sanitize_sql([:conditions]) conditions << " AND (#{sanitized_conditions["sqlSegment"]})" unless sanitized_conditions["paramArray"].nil? param_array = param_array + sanitized_conditions["paramArray"] end end if param_array.nil? [:conditions] = conditions else [:conditions] = [conditions] + param_array end if [:order] && @reflection.[:order] [:order] = "#{[:order]}, #{@reflection.[:order]}" elsif @reflection.[:order] [:order] = @reflection.[:order] end # Build options specific to association () () # Pass through args exactly as we received them. args << @reflection.klass.find(*args) end end |