lib/scaffolding_extensions/meta_model.rb
# Merges the record with id from into the record with id to.  Updates all 
# associated records for the record with id from to be assocatiated with
# the record with id to instead, and then deletes the record with id from.
#
# Returns false if the ids given are the same or the scaffold_session_value
# criteria is not met.
Merges the record with id from into the record with id to.  Updates all
associated records for the record with id from to be assocatiated with
the record with id to instead, and then deletes the record with id from.

Returns false if the ids given are the same or the scaffold_session_value
criteria is not met.
Merges the record with id from into the record with id to . Updates all associated records for the record with id from to be assocatiated with the record with id to instead and then deletes the record with id from . Returns false if the ids given are the same or the scaffold_session_value criteria is not met .
def scaffold_merge_records(from, to, options)
    from, to = from.to_i, to.to_i
    return false if from == to
    from_object = scaffold_get_object(from)
    return false unless scaffold_session_value_matches?(from_object, options[:session])
    to_object = scaffold_get_object(to)
    return false unless scaffold_session_value_matches?(to_object, options[:session])
    scaffold_transaction do
      scaffold_all_associations.each{|reflection| scaffold_reflection_merge(reflection, from, to)}
      scaffold_destroy(from_object)
    end
    true
  end
def scaffold_merge_records ( from , to , options ) from , to = from . to_i , to . to_i return false if from == to from_object = scaffold_get_object ( from ) return false unless scaffold_session_value_matches? ( from_object , options [ :session ] ) to_object = scaffold_get_object ( to ) return false unless scaffold_session_value_matches? ( to_object , options [ :session ] ) scaffold_transaction do scaffold_all_associations . each { | reflection | scaffold_reflection_merge ( reflection , from , to ) } scaffold_destroy ( from_object ) end true end
Merges the record with id from into the record with id to.
Merges the record with id from into the record with id to .
from
<not_specific>
to
<not_specific>
options
<not_specific>