A Blog With Rails

Introduction:

Warning this only works on Mac OS.

Now before you start thinking your going to make the next WordPress, let me just say we are only going to be making the MVP of a blogging site, that’s right a MVP. What is a MVP you may ask ? It stands for Minimum Viable Product, this thing we are about to build is just a web app that has CRUD functionality. What is CRUD you ask ? CRUD is Create Read Update Destroy.

Don’t be afraid of the terminal, the terminal is your friend for life 🙂 you just got to treat it right.

Up and running:

  1. Install Home Brew, is manages the software you need to manage all the software, your going to use to make software. Just follow the instructions on here: https://brew.sh/
  2. Install Bundler, it manages the specific Ruby software libraries for your application. Type the following command “gem install bundler”.
  3. Install Nokogiri, it gives Ruby the ability to understand HTML and CSS among other things. Type the following command “gem install nokogiri”. This is going to take awhile, chill out and take a break you have been working too hard 🙂
  4. Install Rails, its the thing that you build on top of, to make your web application. Ruby the language has libraries for doing different things. Rails is just a really big library for making web based applications.  As you may have guess just type in “gem install rails”.

 

Making a Rails App:

  1. CD into a folder you would like to be in and run the following command “rails new <name of your app here> -T “
  2. Now if you look into the folder you just ran this command in, you will see a folder with the name of your app. Open this with your favorite text editor, VSCode is always a good choice.
  3. CD into the newly created folder, and make your database. You can do this by running “rails db:create” and then running “rails db:migrate”. What this is doing is creating a database, and then populating it with boiler plate info.
  4. Now run “rails s” and go to the URL is gives you. You should see your app, YAY you made your first rails app 🙂 If the URL isn’t working try using http:127.0.0.1/8080 or http:127.0.0.1/3000.

 

Actually making the Blog:

  1. Run “rails g scaffold Blog title:string body:text”. What this command will do is create a Blog object, that has a title and a body and can be stored in our database. Rails knows this since “g” is for generate, “scaffold” is for create everything for me, and the rest is specify what type of things you want there to be, in the object you are creating.
  2. Now you got to let the database know about this blog object you made. To do so simply run “rails db:migrate”
  3. Finally the moment you have been waiting for, run your app with “rails s” and ta-da you go your self a working rails app 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s