Learning Ruby On Rails: Day 5

Morgan Fogarty
Oct 5, 2018 · 3 min read

YIL (I couldn’t write a post yesterday because, well… I went to the Beyoncé concert. I learned stuff. I just couldn’t write about it… because Beyoncé).

But here’s the stuff I learned/did yesterday:

  • rails new demo to create a new project. I did this in a directory folder where I keep all my tutorials.
  • Navigated into demo and then typed bin/rails about and that told me all about the project I’d just made!
bin/rails about
  • Typed bin/rails server into the command line.
server running on localhost:3000

Then a review of MVC as it pertains to Rails:

  • Rails accepts incoming requests from the browser.
  • It decodes the request to find a controller.
  • It calls an action method in that controller.
  • The controller invokes a view to display the result to a user.

Next, I started making a “Hello World” app. For this app, I needed a controller a view and a route to connect them.

Why didn’t I need a model?

Because we have no data.

Cool. Got it. Let’s make the thingy.

In the command line I typed bin/rails generate controller Say hello goodbye. And check this out!

This command created a controller and the names of the actions we’ll take! rails generate logs files and directories and notes when it adds new Ruby files or directories to the application. So cool.

Then I got a bunch of feels because I started thinking about how many times I created these boiler plate chunks of code by hand in JavaScript. And then I thought about how the Rails approach works nicely with how my brain works. It forces me to think about what type of functionality I’ll want to have in my controller before simply making a controller file. So in one fell swoop, I’m conceptualizing the creation of the file and the function of the file itself. And I’m thankful for this.

Here’s what the controller looks like thus far:

lil cutie

K bye.

Next post, here.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store