Learning Ruby On Rails: Day 8

Morgan Fogarty
Oct 15, 2018 · 2 min read

I have this tiny “Hello world” app.

It has one page.

Now I will give it another page.

Each page will correspond with a separate view. For this new page I will use a new action method (goodbye) which will be in the same controller I’ve been working with(say_controller.rb).

New action method. Same controller. Here we go.

I add html to goodbye.html.erb so that it will show “Goodbye”. That’s fine but I’d really like to add links between both pages, too.

For links I will use a helper method!

link_to() creates a hyperlink to an action.

So in my hello.html.erb I add a link to the goodbye view. The code looks like this:

On line 7, "Goodbye" is the text of the hyperlink. say_goodbye_path is the precomputed value that Rails makes available to application views. It evaluates to say/goodbye path.

And the page looks like this:

Now I will add a link from the “Goodbye” page to the “Hello” page.

It looks like this:

Also most importantly TIL that if I type cowsay meow into my terminal I will get an emoticon cow saying “meow”. It looks like this:

And I had to run brew install cowsay in order to have this ability. I regret nothing.

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