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 demoto create a new project. I did this in a directory folder where I keep all my tutorials.
- Navigated into
demoand then typed
bin/rails aboutand that told me all about the project I’d just made!
bin/rails serverinto the command line.
- Then I navigated to http://localhost:3000/ and yay!
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.
Here’s what the controller looks like thus far:
Next post, here.