I have a registration form.
When a user logs in, the application must save the data in the enrollments
table and in the users
table. (I need this separation because the user profile may change, but the data that he entered for this particular registration must be archived. Therefore, even if the user changes his last name later, I will have his initial information in the registration form.)
So, I was thinking about storing data in an enrollments
table, and then has an after_create call like this ...
class Enrollment < ActiveRecord::Base after_create :save_corresponding_user def save_corresponding_user user = User.new user.full_name = self.user_full_name user.email = self.user_email user.mobile_phone = self.user_mobile_phone user.save end end
The problem is that if you save the user for some reason. How can I roll back and destroy just saved data from the enrollments
table?
source share