method

add_join_records

add_join_records(association)
public

No documentation available.

# File activerecord/lib/active_record/fixture_set/table_row.rb, line 186
        def add_join_records(association)
          # This is the case when the join table has no fixtures file
          if (targets = @row.delete(association.name.to_s))
            table_name  = association.join_table
            column_type = association.primary_key_type
            lhs_key     = association.lhs_key
            rhs_key     = association.rhs_key

            targets = targets.is_a?(Array) ? targets : targets.split(/\s*,\s*/)
            joins   = targets.map do |target|
              join = {}

              if rhs_key.is_a?(Array)
                composite_key = ActiveRecord::FixtureSet.composite_identify(target, rhs_key)
                composite_key.each do |column, value|
                  join[column] = value
                end
              else
                join[rhs_key] = ActiveRecord::FixtureSet.identify(target, column_type)
              end

              if lhs_key.is_a?(Array)
                lhs_key.zip(model_metadata.primary_key_name).each do |fkey, pkey|
                  join[fkey] = @row[pkey]
                end
              else
                join[lhs_key] = @row[model_metadata.primary_key_name]
              end

              association.timestamp_column_names.each do |col|
                join[col] = @now
              end
              join
            end
            @table_rows.tables[table_name].concat(joins)
          end
        end