Learning Ruby On Rails: Day 9

The tiny “Hello World” app has two pages that link to each other. It works!

Now to break it so I can see why it works.

First I added a typo in the code:

I changed Time.now()(a Ruby method on a Time object) to Time.know()(a nonsense method on a Time object).

In the browser, the following appeared

Then I tried messing with the URL and in the browser. A Routing Error appeared:

These error messages are so helpful and clear. The Routing Error message even has an input field where you can search for the correct path:

What a dream.

So in my first few days of learning Ruby on Rails, I’ve done the following:

It’s been real.

I have a couple Q’s though:

@addition = <%= 1 + 3 %>

Answer to Question 1: I can create new controller methods in the text editor! But then the view templates aren’t auto-created by Rails.

When I first created the controller, I typed rails generate controller Say hello goodbye and the views for hello and goodbye were simultaneously created. If I run that command again with a new method name, I get a conflict error:

So I’ll add them via the text editor and then I’ll be sure to add the corresponding views.

Answer to Question 2: Because it’s erb! That’s gotta go in the html.erb file, kid.

Next post, here.

I’m just a girl, standing in front of some code, asking it to love her.

I’m just a girl, standing in front of some code, asking it to love her.