/MindPrep_blog

MindPrep Blog app is a classic example of a blog website, created as a fully functional website that shows the list of posts and empowers readers to interact with them by adding comments and liking posts.

Primary LanguageRubyMIT LicenseMIT

📗 Table of Contents

📖 MindPrep Blog

MindPrep Blog is a classic example of a blog website, created as a fully functional website that shows the list of posts and empowers readers to interact with them by adding comments and liking posts.

🛠 Built With

Tech Stack

Client
Server
Database

Key Features

  • Fully functional website
  • Leverages RDMS (PostgreSQL)
  • Mini Design
  • Input SQL queries with ActiveRecord
  • Implement preprocessed HTML file with embedded Ruby code.
  • Use layouts and templates for shared content.
  • Write unit tests for models.
  • Secure app from n+1 problems.
  • Use validations for models.

(back to top)

🚀 Live Demo

This section will be updated as soon as it is ready.

(back to top)

💻 Getting Started

Prerequisites

In order to run this project you need:

  • IDE or code editor: VsCode, atom, sublime...
  • To have Ruby, RoR gem and Git installed on your system.

Setup

Setting Up PostgreSQL

  • The postgres installation doesn't setup a user for you, so you'll need to follow these steps to create a user with permission to create databases
$  sudo -u postgres createuser mindprep -s

Clone this repository

Clone this project on your local machine using the following command on your terminal:

  git clone https://github.com/abayomiolaoye/MindPrep_blog.git
  cd MindPrep_blog

Install linter

$  bundle init
$  bundle install
  • Run linter
$  rubocop .
  • In auto-correct mode, RuboCop will try to automatically fix offenses:
$ rubocop -A
# or
$ rubocop --auto-correct-all

Create the database

$   rails db:create   # or
$   rake db:create

Starting up the Web Server

$   rails s # or
$   rails server

Generate Controller

  • We need a Controller. Since everything goes through that, let's go ahead and generate one:
$  rails generate rspec:install
  • This should give us a Controller and a View

Listing Existing Routes

  • You can now visit http://localhost:3000 to view your new website! You can also execute the rails routes command in your terminal to produce the same output.

Generate rspec

  • At the first you need to include those lines in your Gemfile
  gem 'rails-controller-testing'
  gem 'rspec-rails'
$  rails generate rspec:install
  • This should generate some files that you will need to run your tests
  • Then run:
$  rspec spec     # to test if your tests are passed

Generate migration files

  $  rails generate migration CreateUsers
  $  rails generate migration CreatePosts
  $  rails generate migration CreateLikes
  $  rails generate migration CreateComments
  $  rails generate migration AddUserRefToComments
  $  rails generate migration AddPostRefToComments
  $  rails generate migration AddUserRefToLikes
  $  rails generate migration AddPostRefToLikes
  $  rails generate migration AddUserRefToPosts

Generate model

  $  rails generate model User name  photo bio:text posts_counter:integer
  $  rails generate model Post  title  text:text comments_counter:integer likes_counter:integer author:references
  $  rails generate model Like author:references post:references
  $  rails generate model Comments text:text author:references post:references

Generate model

  $  rails generate model User name  photo bio:text posts_counter:integer
  $  rails generate model Post  title  text:text comments_counter:integer likes_counter:integer author:references
  $  rails generate model Like author:references post:references
  $  rails generate model Comments text:text author:references post:references

Generate Schema

  • To push the Migration into the database
  $   rails db:migrate
  • We use the seeds.rb file to records in the database
  • To drop, create a table and to migrate and send the seed into the database:
  $   rails db:drop db:create db:migrate db:seed
  • To check available routes
  $   rails routes

(back to top)

👥 Authors

👤 Oluwatoyin Olaoye

👤 Sammuel LEKPOR

(back to top)

🔭 Future Features

  • Use React for the Views
  • Implement some mmotions and transitions

(back to top)

🤝 Contributing

Contributions, issues, and feature requests are welcome!

Feel free to check the issues page.

(back to top)

⭐️ Show your support

If you like this project, a star will be appreciated.

(back to top)

🙏 Acknowledgments

I would like to thank Paul Mosanya for his unquantifiable contributions

(back to top)

(back to top)

📝 License

This project is MIT licensed.

(back to top)