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.
- 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.
To get a local copy for this project and running follow these simple example steps.
- You need to have git installed in your machine.
- Install a recent version of Postgres.
- Already install Rails
- 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
$ git clone https://github.com/evans22j/Blog-App.git
$ cd Blog-app
- use PostgreSQL database
$ rails new hello-rails --database=postgresql #or
$ rails new hello-rails -d postgresql
$ cd hello-rails # Move into the application directory
$ 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
$ rails db:create # or
$ rake db:create
$ rails s # or
$ rails server
- 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
- 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.
- 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
$ 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
$ 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
To push the Migration into the database
$ rails db:migrate
This project is build with:
👤 Evans Sitibekiso
- GitHub: @evans22j
- Twitter: @Evans_22J
- LinkedIn: @Evans Sitibekiso
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
Give a ⭐️ if you like this project!
- Thanks to microverse for this project
- Inspiration
- etc
This project is MIT licensed.