Topic: Add two rows in single submission

Hi friends,

I am a new bee on ROR, can anyone help me out in the below issue:

say there are two user entries in the form
formname - production
description - add, edit, delete production forms

the above information is getting updated correctly now
but what i need is i have to update like
production_add and description
production_edit and description
production_delete and description

and i couldnt find, where exactly the scaffold is adding the rows from
i have been struggling to find the solution
can anybody help me in this regard please

Re: Add two rows in single submission

Can you make your question clearer?  Maybe explain a little more?

Re: Add two rows in single submission

I have a form, there are two inputs from the user
say,
input 1 --- production
input 2 --- some description

on submission of the form, i have to update a table with following rows


production_add some description
production_edit some description
production_modify some description
production_view some description

Re: Add two rows in single submission

Adding 2 rows to a table using a single API call can be accomplished using straight SQL:

####################################################################
# Connect to environment specific database
####################################################################
def db_connect
  data = ERB.new(File.open(File.dirname(__FILE__) + '/../../config/database.yml').read)
  conf = YAML::load(data.result)
  ActiveRecord::Base.establish_connection(conf[ENV['RAILS_ENV']])
  ActiveRecord::Base.connection
end

sql = %[
  INSERT INTO mytable VALUES(NULL, 'whatever'),(NULL, 'another-row')
]
@dbconnection = db_connect if @dbconnection.nil?
res = @dbconnection.insert(sql)


Make sure the path to your database.yml file is correct in relation to the controller file.