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:
- 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/
- Install Bundler, it manages the specific Ruby software libraries for your application. Type the following command “gem install bundler”.
- 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 🙂
- 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:
- CD into a folder you would like to be in and run the following command “rails new <name of your app here> -T “
- 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.
- 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.
- 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:
- 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.
- Now you got to let the database know about this blog object you made. To do so simply run “rails db:migrate”
- 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 🙂