4 Routes

I have no clue on what to do here… Please HELP !

Now that we have a controller, let’s move on to the second part of the request/response cycle and create a route.

Open config/routes.rb and underneath line 1, type:

get ‘welcome’ => ‘pages#home’

Error when I type get ‘welcome’ +> ‘pages#home’ under line # 1 in editior

Oops! The test returned an error. Maybe you have a syntax error, or a typo. Hide error.
app/controllers/pages_controller.rb:2:in <class:PagesController>': undefined methodget’ for PagesController:Class (NoMethodError)

1 Like

I’m getting the same error. I can get to ‘routes.rb’ not ‘config/routes.rb’ its really weird. becasue routes.rb doesn’t fall under config

I am getting this. Did you find a solution?

Insert this and you get it working!

  1. Rails.application.routes.draw do
    2.get ‘welcome’ => ‘pages#home’

whats the difference in it ?

I’m still getting a syntax error…not sure what to do to proceed

Oops! The test returned an error. Maybe you have a syntax error, or a typo. Hide error.
app/controllers/pages_controller.rb:1:in `<top (required)>’: uninitialized constant ApplicationControlle (NameError)

‘pages#home’ letter p of pages is not capital it must be written a small letter

solution

When in File Navigator, Don’t go to “config.ru”… instead open the file “congif” then "routes.rb .

after opening you’ll find a line “Rails.application.routes.draw do” and a lot pf grey lines, ignore them and type under the first line “the line with colors” the code given in the instructions.

hope it works for you.

@landen_lewis

Just to specify:

In routes.rb, when we type

get 'welcome' => 'pages#home'

We are telling if we access to http://localhost/welcome we enter inside home.html.erb inside the pages folder. The # is used for separating the folder and the file. In basic routes allow us to manipulate url and change them easily.

1 Like