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:

  1. Allow users to share and view links
  2. Allow users to sign-up, sign-in, and sign-out
  3. Allow signed-in users to submit and edit links
  4. Allow signed-in users to upvote or downvote links
  5. 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 the Devise 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 1200+ tech skills courses.