We will need the following two models:
User: Since the model's table will be generated from the
Auth
package's migration, the columns will already be generated. The columns we need areusername
andpassword
.Post: Each post has a
content
and acreated_at
property. Since each post can only be published by a single user and each user can publish many posts, there is abelongs_to
relationship between posts and users and ahas_many
relationship between users and posts. Thus, an additionaluser_id
property must be added for the relationship.