How do I map the URL "/pages/home" to the pages controller's "home" action?


#1

I'm confused with the same step. I referred back to the first Rails lesson. I can see that the necessary code should be similar to:

get 'welcome' => 'pages#home'

But I'm not yet familiar enough with the vocabulary of "mapping a request for a url" or "home actions" to figure out which parts need to be adjusted for this project.


In the routes file (config/routes.rb), map the request for the url /pages/home to Pages controller's home action
#2

@zivkovic.jeff

                # ↓ use the `pages` controller's `home` action
get 'welcome' => 'pages#home'
   # ↑ this is the url path (/welcome)

So now, you need to:

map the request for the url /pages/home to Pages controller's home action

So, first the URL path:

get "pages/home"
   # ↑ you can put a slash (/) there if you want

...then the action:

"pages#home"

...and when we put those two together, we get this:

get "pages/home" => "pages#home"

#3

Wow. That was quick. And helpful. Thank you.


#4

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.