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.
- You should have Ruby 2.7.1
- You need to have Rails 6.0.3.2
- You need to have Yarn v1.22.4
-
Clone this repository with
git clone https://github.com/Georjane/Micro-Reddit.git
-
Go inside this repo locally by typing
cd Micro-Reddit
-
Run
bundle install
to install all ruby dependecies -
Run
yarn
to install js dependencies -
Run
bin/rails db:migrate
to create necessary tables in database
- Run
bin/rails console
to start the console linked to this app
To create a new user
user = User.create({ username: 'user_1', email: 'user_1@reddit.app', password: 'password_of_user'})
=> username, email, password are required
To create a new post
post = Post.create({ title: 'post_1', body: 'This is post 1', user_id: 1})
=> 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})
=> 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
- User and Post models: run
User.first.posts
orPost.first.user
- Post and Comment models: run
Post.first.comments
orComment.first.post
- User and Comment models: run
User.first.comments
orComment.first.user
There are two ways of contributing to this project:
- If you see something wrong or not working, please open the issue in issue section
- If you see something to improve or to correct, and you have a solution to that, follow the below steps to contribute:
- Fork this repository
- 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 - Open the cloned repository which appears as a folder on your local computer with your favorite code editor
- Create a separate branch off the master branch,
- Write your codes which fix the issue you found
- Commit and push the branch you created
- Open a pull request, comparing your new created branch with our original master branch here
- Github: @descholar-ceo
- Twitter: @descholar3
- LinkedIn: MUGIRASE Emmanuel
- Github: @Georjane
- Twitter: @WittyJany
- LinkedIn: Witah Georjane
Give a ⭐️ if you like this project!