How to create a record in another table?

Hi

In my Delphi GUI apps, it is common functionality
a) to select a row
b)then ‘append to’ ie create a row to another table with similar
table structure

I guess the analogy would be to copy a record to another table by
clicking an action link

How can we do it wth ActiveScaffold ?

I think the solution is to copy the record as follows :-

def self.add_transfer_action
# The copy action
define_method(:copy) do
new
end

# Override the do_new to implement copy behavior
define_method(:do_new) do
  super
  if params["action"] == "transfer"
    model = active_scaffold_config.model
    copied_record = model.find(params[:id])


   # how do I specify the target controller ?
    model.columns.each do |column|
      @record.send("#{column.name}=",
        copied_record.send("#{column.name}")) unless column.name
        model.primary_key
    end
   #
  end
end

end

Q. How and where do I specify the target table in the above-mentioned
code

I’m not sure how it will be different for ActiveScaffold as I don’t
use it, but to do the actions you described in RoR, you can use
the attributes property:

Assuming that you already have the source row called src,
you can do

target_row = TargetTable.new(src.attributes)