Georjane / Micro-Reddit

This project helps us to practice data modeling and putting our active record knowledge to practice by building our own lightweight Reddit clone.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Micro reddit

Project description

This project is for learning purpose just to get familiar with Ruby on Rails(Active record). It is gotten from The Odin Project.

In it, we built a simple micro-reddit models for users, posts and comments, with ruby on rails. It doesn't have neither User Interface nor Controllers, just models only.

Tools and technologies used to build this project

  1. Ruby 2.7.1
  2. Ruby on Rails 6.0.3.2

Running and testing it locally

Prerequisites

  1. You should have Ruby 2.7.1
  2. You need to have Rails 6.0.3.2
  3. You need to have Yarn v1.22.4

Setup

  1. Clone this repository with git clone https://github.com/Georjane/Micro-Reddit.git

  2. Go inside this repo locally by typing cd Micro-Reddit

  3. Run bundle install to install all ruby dependecies

  4. Run yarn to install js dependencies

  5. Run bin/rails db:migrate to create necessary tables in database

Testing

  1. Run bin/rails console to start the console linked to this app

Commands for testing the functionality

To create a new user

user = User.create({ username: 'user_1', email: 'user_1@reddit.app', password: 'password_of_user'})

Requirements

=> username, email, password are required

To create a new post

post = Post.create({ title: 'post_1', body: 'This is post 1', user_id: 1})

Requirements

=> title, body, user_id are required

=> user_id should be an integer and exists in table of users

To create comment

comment = Comment.create({ post_id: 1, body: 'This is a comment on post 1', user_id: 1})

Requirements

=> post_id, body, user_id are required

=> post_id, user_id should be all integers and both exist in the posts and users table respectively

NOTE: To test if validations are working, just try to violate any requirement on any command, and see what happens

To test associations

  1. User and Post models: run User.first.posts or Post.first.user
  2. Post and Comment models: run Post.first.comments or Comment.first.post
  3. User and Comment models: run User.first.comments or Comment.first.user

Contributing

There are two ways of contributing to this project:

  1. If you see something wrong or not working, please open the issue in issue section
  2. If you see something to improve or to correct, and you have a solution to that, follow the below steps to contribute:
    1. Fork this repository
    2. Clone it on your local computer by running git clone https://github.com/Georjane/Micro-Reddit.git Replace your username with the username you use on github
    3. Open the cloned repository which appears as a folder on your local computer with your favorite code editor
    4. Create a separate branch off the master branch,
    5. Write your codes which fix the issue you found
    6. Commit and push the branch you created
    7. Open a pull request, comparing your new created branch with our original master branch here

Authors

1. MUGIRASE Emmanuel

2. Witah Ngu Georjane

Show your support

Give a ⭐️ if you like this project!

Acknowledgment

About

This project helps us to practice data modeling and putting our active record knowledge to practice by building our own lightweight Reddit clone.


Languages

Language:Ruby 78.1%Language:HTML 12.2%Language:JavaScript 8.2%Language:CSS 1.5%