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 πŸ™‚

“?” in Angular 5

As you an Angular component has a life cycle, much life us humans. In the beginning we are nothing, we do a bunch in the middle and then we die πŸ™‚ However if you want to call a certain service in yourΒ “ngOnInit” to dump some values into a var that appears in your html, your going to have a bad time. Or at least angular is by throwing a lot of errors in your console, I mean it will still work.

To get rid of these errors all you have to do it the following add a “?” at the end of the end of the var that’s in the html, and ta-da errors gone. This works since the “?” tells Angular to chill out there will be a value you there “eventually”. Hmm… but why eventually you may ask ? Its because two functions before “ngOnInit” get called , the very first one being the constructor of the class and the second being the “ngOnChanges” method. So for the execution of the first two methods its asking “WTF where is this thing in the html in the .ts file ?”Β  which makes throw errors.

JS for beginners, the TLDR version – Part 1

Java Script is not different then other languages ! It’s unique and special in its own way.

JavaScript has everything you would expect to find all computer programming languages:

  • For loops
  • While loops
  • Do – Then loops
  • If – Else Statements
  • Switch Statements
  • Classes and Objects
  • Functions
  • Dynamically Typed (most languages have this)

However it has some very weird and interesting differences:

  • It has no truth, it is a truthy language
  • You can stuff a function into a variable
  • There are more ways then one to do the same thing

Django – Part 1

Django_Reinhardt_(Gottlieb_07301)
Django Reinhardt a jazz legend

No I am not talking about this guy to the left.

I am actually talking about the web framework written in Python. Now the reason that I have even started learning this, is cause I wanted to see what all the hype is about. Plus I wanted to get a better understanding of the Python language its self.

Now I come from the world of Express.js which is kinda of like Flask, in terms of its bare-bones nature. So when I first saw Django I was reminded of ASP.NET, and Ruby on Rails. You might be thinking what sort of nonsnese is this kid spouting ? How the can he put two of the most loved opens sourced projects next to, Microsofts evil ways. And to that I respond with: A) Microsoft is not evil, and B) I say that since all three of these frameworks have so much built in functionality, that they become opaque. Opaque as in not transparent as in have to use for along time to really understand how they work.

Anyways this is a post letting you guys or gals out there know, I am going to be making a tutorial series as I start to learn the framework.

Yes I know that all my posts are starting to seem like tutorials or updates. I promise they will eventually be about something else πŸ˜…