DEV Community

Cover image for Rails: Up
Cicada0315
Cicada0315

Posted on

Rails: Up

Step1: Deciding type of website

There is one website that I really enjoy which contains bunch of ramdom stories, images or gifs. I can even upload them by myself. Since I am practicing, I thought, it will be better to mimic one of the familiar website so I choose to make my version of this website.

Step2: Plans

Models

I used below link do draw relational diagrams. I will have four models as you can find in below as well.

link: https://dbdiagram.io/home

// Creating tables
Table users {
  id int [pk, increment]
  last_name string
  first_name string
  username string
  email string
  password string
}

Table posts {
  id int [pk, increment]
  user_id integer
  title string
  link string
  content text
  view integer

}

Table comments {
  id int [pk, increment]
  user_id integer
  post_id integer
  content text
}

Table likes {
  id int [pk, increment]
  user_id integer
  post_id integer
}

// Creating references
// You can also define relaionship separately
// > many-to-one; < one-to-many; - one-to-one
Ref: posts.user_id > users.id

Ref: comments.user_id > users.id
Ref: comments.post_id > posts.id

Ref: likes.user_id > users.id
Ref: likes.post_id > posts.id
Enter fullscreen mode Exit fullscreen mode

Controllers

apllication_cotroller
comments_controller
likes_controller
posts_controller
users_controller
sessions_controller
static_controller
Enter fullscreen mode Exit fullscreen mode

Views

layouts: application
posts: new, edit, show, index, kups, topups, newups, _form, _post
sessions: new
static: about, _errors
users: new
Enter fullscreen mode Exit fullscreen mode

Step3: Implement

static

aboutUps- explained about the website

users

signup

sessions

login
logout

posts

user can upload files, write content, provide link for image or gif.
user can modify or delete the post they uploaded.
user can comment post.
user can like(thumbsup) the post.
whenever people see the post then the view is incremented.

Reference

https://getbootstrap.com/
https://guides.rubyonrails.org/v5.2.0/active_storage_overview.html
https://github.com/Ejguzman3988/ft-020121-ImgTube

Comment

There was a lot of different things that I need to consider. It was little bit confusing time to time but I managed to make decent website. It is always fun to make new website. One of my feature, uploading files view is not neat since I cannot use javascript. I am so excited for the future project that will be done using javascript. I will do much more and efficient way than this one.

Top comments (0)