User The user table has username
and email
of type string
and a karma
of type integer
.
Post The post table has a title
of type string, content
of type text
, and a reference to a user
Community The community table has a name
of type string
UserCommunity The user_communities join table has foreign key references to a user
and a community
.
Accociations
- A
user
can have manyuser_communities
and manycommunities
throughuser_communities
- A
community
can have manyuser_communities
and manyusers
throughuser_communities
- A
user
can have many posts and apost
belongs to exactly oneuser
. - A
user_communities
belongs to auser
and acommunity
.
Additional Methods
User
Instance method get_username
returns the user's username
Instance method get_karma
returns the user's karma
rating
Community
User
- A username must be at least 6 characters in length
- A username must be unique
Community
- A community name must be unique