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
1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 |
# File 'lib/active_record/connection_adapters/ibm_db_pstmt.rb', line 1369 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 |