All threads / How do I resolve Rails routing error: No route matches [GET] "/pages_about_path"?
Ask A Question


You’re not receiving notifications from this thread.

How do I resolve Rails routing error: No route matches [GET] "/pages_about_path"?

Alfred Montalvo Jr asked in Rails

I am running into a routing error for a get action when I try to render an html erb view from the '../views/pages' folder via a navbar link.

I have reviewed the routes.rb file and the output from "rake routes" to verify that route for the 'about' view has been defined in the routes file.

So I do not understand why the routing error is happening when the path is defined in the route file correctly.

I have listed below the url helper that I am using in the navbar, my routes.rb file and the output from rake routes.

Does anyone have any suggestions to resolve the routing error that I am encountering?

url helper defined in _nav.html.erb:

<li class="nav-item">
  <a class="nav-link" href="pages_about_path">About</a>


Rails.application.routes.draw do
  root to: 'pages#index'  
  get 'pages/about', to: 'pages#about'  
  # For details on the DSL available within this file, see

rake routes output:

Prefix Verb URI Pattern Controller#Action
root GET / pages#index

pages_about GET /pages/about(.:format) pages#about

Hey Alfred,

Can you post your actual error?

Actually, think I spotted your error. You're not using ERB for rendering the link.

<a class="nav-link" href="pages_about_path">About</a>

That should be:

<%= link_to "About", pages_about_path, class: "nav-link" %>

pages_about_path is a helper in Rails to generate the string /pages/about for your route. You need to use ERB to make sure it runs that code and outputs href="/pages/about" instead of outputting the raw string of href="pages_about_path".

Hi Chris,
thank you very much for providing the solution to the routing error I was running into.

Thank you for the information

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 62,791+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.