Skip to content

Conversation

@gjaldon
Copy link

@gjaldon gjaldon commented Sep 15, 2016

Most of the explanations are in the commits but there some comments to explain some of the code that may be unclear.

We want to start recording anonymous users so we can store
relevant data such as a fake name, fake avatar, and when
their chatroom was last viewed by an admin.

We generate the relevant migrations and add the fields we
need for an `anonymous_user`. Since the frontend generates
a UUID for every anonymous user, the UUID would be perfect as
`id` for our AnonymousUser records. We use the `uuid` type
for the `id` column of our AnonymousUser and set it to
not autogenerate an id. That way, we use the UUID passed to
us from the frontend as `id` every time we create a new
AnonymousUser record.

Now that we have an AnonymousUser, we can associate it with
Message so we can easily get all the messages sent by a user.
Note that there are a few extra steps for this because we
are using a `:uuid` type as `id` instead of the default
`:integer`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant