There are several options you could implement to make this work:
Active resource
Like others, you can use ActiveResource . After reading your comments, this seems like a solution that you want to avoid because of the multi-query aspect.
Receiving controller
You may have a controller in your second rails application that receives data and creates records from it.
class RecordReceiver < ActiveRecord::Base def create params[:data][:posts].each do |p| Post.create(p) end end end
You can skip this controller in the API namespace, which is a pretty clean solution if it runs correctly.
Share Database
You can share one database in two applications. This means that you will not need to send data from one model to another, it will already be there. This is the least work for you as a developer, but it may not be possible depending on your system architecture.
Two databases in each application
In each application, you can implement several databases, for example:
#Add to database.yml other_development: adapter: mysql database: otherdb_development username: root password: host: localhost other_production: adapter: mysql database: otherdb_production username: root password: host: localhost
Then define your models as follows:
class Post < ActiveRecord::Base end class PostClone < ActiveRecord::Base establish_connection "other_
Now your Clone model will point to the current database, and the PostClone model will point to another database. Having access to both, you can copy data when you need using the basic methods of the model.
Conclusion
Since you do not want to use ActiveResource, I would recommend that you simply split the database between applications. If this is not possible, try to have two models, each of which is collected in a different database. Finally, the host controller is a valid, albeit slower option (since it must execute an HTTP request over database queries)