Skip to content

The Blog app will be a classic example of a blog website. You will create a fully functional website that will show the list of posts and empower readers to interact with them by adding comments and liking posts.

License

Notifications You must be signed in to change notification settings

evans22j/Blog-App

Repository files navigation

Blog-app

Description

The Blog app will be a classic example of a blog website. You will create a fully functional website that will show the list of posts and empower readers to interact with them by adding comments and liking posts.

Learning objectives

  • Diagram a data model clearly and explain what it's doing.
  • Understand how to use medium-fidelity wireframes to create a UI.
  • Use controllers to handle requests and render empty views.
  • Install Ruby on Rails framework.
  • Use Ruby Gems as a software packages system.
  • Understand Rails naming conventions.
  • Use params from browser requests in a safe way.
  • Write tests for controllers.
  • Understand what ORM is.
  • Use database migration fails to maintain database schema.

Getting Started

To get a local copy for this project and running follow these simple example steps.

Prerequisites

  • You need to have git installed in your machine.
  • Install a recent version of Postgres.
  • Already install Rails

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 blog-app -s

Clone this repository

$ git clone https://github.com/evans22j/Blog-App.git
$ cd Blog-app

Creating the hello-rails Application

  • use PostgreSQL database
$   rails new hello-rails --database=postgresql  #or
$   rails new hello-rails -d postgresql

$   cd hello-rails # Move into the application directory

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'
  • Then run:
$  rails generate rspec:install
  • This should generate some files that you will need to run your tests

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 Schema

To push the Migration into the database

  $   rails db:migrate

Built With

This project is build with:

  • Ruby
  • Ruby on Rails

Authors

👤 Evans Sitibekiso

🤝 Contributor

Contributions, issues, and feature requests are welcome!

Feel free to check the issues page.

Show your support

Give a ⭐️ if you like this project!

Acknowledgments

  • Thanks to microverse for this project
  • Inspiration
  • etc

📝 License

This project is MIT licensed.

About

The Blog app will be a classic example of a blog website. You will create a fully functional website that will show the list of posts and empower readers to interact with them by adding comments and liking posts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published