lib/scaffolding_extensions/model/sequel.rb
# Updates associated records for a given reflection and from record to point to the
# to record
Updates associated records for a given reflection and from record to point to the
to record
Updates associated records for a given reflection and from record to point to the to record
def scaffold_reflection_merge(reflection, from, to)
      case reflection[:type]
        when :one_to_many
          foreign_key = reflection[:key]
          table = reflection.associated_class.table_name
        when :many_to_many
          foreign_key = reflection[:left_key]
          table = reflection[:join_table]
        else
          return
      end
      db[table].filter(foreign_key=>from).update(foreign_key=>to)
    end
def scaffold_reflection_merge ( reflection , from , to ) case reflection [ :type ] when :one_to_many foreign_key = reflection [ :key ] table = reflection . associated_class . table_name when :many_to_many foreign_key = reflection [ :left_key ] table = reflection [ :join_table ] else return end db [ table ] . filter ( foreign_key => from ) . update ( foreign_key => to ) end
Updates associated records for a given reflection and from record to point to the
to record
Updates associated records for a given reflection and from record to point to the to record
reflection
<not_specific>
from
<not_specific>
to
<not_specific>