app/models/user.rb
# Callback after_create, also used in controllers to ensure users have agents:
Callback after_create, also used in controllers to ensure users have agents.
Callback after_create also used in controllers to ensure users have agents .
def add_agent
    return unless agent_id.blank?
    begin
      self.update_column(:agent_id, Agent.create_agent_from_user(full_name).id)
    rescue ActiveRecord::StatementInvalid
    end
  end
def add_agent return unless agent_id . blank? begin self . update_column ( :agent_id , Agent . create_agent_from_user ( full_name ) . id ) rescue ActiveRecord :: StatementInvalid end end
Callback after_create, also used in controllers to ensure users have agents:
Callback after_create also used in controllers to ensure users have agents :
# TODO: User may not have a full_name on creation so passing it here is possibly redundant. # Interestingly, we are getting users who already have agents attached to them.  I'm not sure why, but it's causing registration to fail (or seem to; the user is created), and this is bad.