class Engine2::StarToManyUnlinkActionBase
Public Instance Methods
invoke_unlink_db(handler, parent, ids)
click to toggle source
# File lib/engine2/action/link.rb, line 56 def invoke_unlink_db handler, parent, ids model = assets[:model] assoc = assets[:assoc] case assoc[:type] when :one_to_many keys = assoc[:keys] if keys.all?{|k|model.db_schema[k][:allow_null] == true} model.db.transaction do ids.each do |id| model.where(model.primary_keys_hash(split_keys(id))).update(Hash[keys.zip([nil])]) end end else handler.halt_method_not_allowed LOCS[:"non_nullable"] end when :many_to_many model.db.transaction do p_pk = Hash[assoc[:left_keys].zip(parent)] ds = model.db[assoc[:join_table]] ids.each do |id| ds.where(p_pk & Hash[assoc[:right_keys].zip(split_keys(id))]).delete end end else unsupported_association end {} end
pre_run()
click to toggle source
Calls superclass method
Engine2::ActionModelSupport#pre_run
# File lib/engine2/action/link.rb, line 51 def pre_run super execute "[action.parent().invoke(), action.panel_close()]" end