I don't understand at all your question, so I'll give you two answers.
First answer:
After search a lot over the Internet and forums, I think I found a solution for your problem that require just one line of code.
I found a good gem that do exactly what you want, but for single models, array of objects and objects. Also, this gem only works for Rails 3.2 and older. I talked with author and he doesn't want support this gem anymore. So I discovered by myself how to support Rails 4.0 and now I'm maintaining this gem.
With this gem, you can easily do the following. (the examples inside
values are just a joke, you will get the correct values when using it in your object).
For objects:
object.to_sql_insert
# INSERT INTO modelName (field1, field2) VALUES ('Wow, amaze gem', 'much doge')
For array of objects:
array_of_objects.to_sql_insert
# INSERT INTO modelName (field1, field2) VALUES ('Awesome doge', "im *Censored* cop")
# INSERT INTO modelName (field1, field2) VALUES ('much profit', 'much doge')
# (...)
For a model:
Model.all.to_sql_insert
# INSERT INTO modelName (field1, field2) VALUES ('Awesome doge', "im *Censored* cop")
# INSERT INTO modelName (field1, field2) VALUES ('much profit', 'much doge')
# (...)
Just see the Github of this project and you'll find how to install and use this wonderful gem.
Second answer:
Following this answer, you can dump all your database simply using mysqldump.
mysqldump [options] db_name [tbl_name ...]
Will generate the script file including the create and inserts necessary for the tables selected. To import the dump you can simply do:
mysql -u <user> -p dbname < mys.dmp
Hope it helps.