When is an active record really inserted into the database
We have a server setup where a rails server is writting into the same database as an java enterprise server. We have an api for the enterprise server implemented on the rails server that will create a user. It looks like this:
user = User.new
user.name = "Test"
user.save()
The problem we are facing now is that when the user create request ret开发者_运维技巧urns the user id to the enterprise server it sometimes is not found by the enterprise server in the database.
When does ActiveRecord insert a new entity into the database? Is there a way to ensure that when save returns that the database insert statement was performed?
The rails version is 2.3.10
You would want to use ActiveRecord callbacks for this. They let you perform an action after the save takes place.
精彩评论