Model Structure
Start building your application, and learn about the model structure you will be using in the application.
We'll cover the following
Before you jump into coding up your application, you need to decide what features your application will have. This will help you break down the implementation and make the coding part easier. The focus of the application created here will be more on the functional aspects, as compared to the aesthetic aspects.
You will create a simple link sharing application. The basic functional features we want are as follows:
- Allow users to share and view links
- Allow users to sign-up, sign-in, and sign-out
- Allow signed-in users to submit and edit links
- Allow signed-in users to upvote or downvote links
- Allow signed-in users to comment on submitted links
Models
The first thing you need to decide is the structure of your models. That is, you need to figure out how many models you need, what attributes they contain, and their association with each other.
In your case, you only require three models: User
, Link
, and Comment
.
-
User
will have an email and a password. This model will be created using theDevise
gem, which will handle the sign-up, sign-in, and sign-out as well. -
Link
will have a title, a url, and a user_id, and will simply contain the list of links added to the application. -
Comment
will have a link_id and a text_body.
Get hands-on with 1400+ tech skills courses.