Remember that I said that when you log in, your ghost user has to be merged with the real user? Well, this is the code for doing it:
class User < ActiveRecord::Base #... def merge(user_id) if user_id != nil user = User.find(user_id) user.weights.each do |weight| weight.user = self weight.save end user.destroy end end end
The problem with this is that it’s very error prone. You have to make sure that every model that is related to the user model gets properly handled.
Leave a Reply