Reputation: 1415
I'm new with Ruby and Rails.
Is there any simple way to export from one instance of application one object with 2 related models and import it to another?
Structure is:
- Model1
- - Model1 has many Model2
- - - Model2 has many Model3
Or may be is there any way to export/import MySql records?
Upvotes: 1
Views: 546
Reputation: 11876
You can use like that:
@new_model1 = @model1.includes(:model2 => [:models3]).clone
@new_model.save()
For switching connection between database you can use magic connection
Upvotes: 1
Reputation: 1684
You have to build it yourself. This looks like a data dump (backup services or CSV dumps). You also can dump it as JSON.
Upvotes: 1