neils
neils

Reputation: 655

embedded ruby link for root page in header

In my application's header, I am trying to get my navbar brand to be a link to the root page of my application. I am using embedded ruby

    <a class="navbar-brand" <%= link_to "Document", "root_path" %></a>
  </div>

Here is the error that I keep getting;

No route matches [GET] "/root_path"


root_path    GET     /   pages#home
about_path   GET     /about(.:format)    pages#about
prices_path  GET     /prices(.:format)   pages#prices
faq_path     GET     /faq(.:format)  pages#faq
terms_path   GET     /terms(.:format)    pages#terms
view_path    GET     /view(.:format)     pages#view
policy_path  GET     /policy(.:format)   pages#policy

My routes page;

Document::Application.routes.draw do
   root "pages#home"
  get "about" => "pages#about"
   get "prices" => "pages#prices"
  get "faq" => "pages#faq", :as => :faq
  get "terms" => "pages#terms"
  get "view" => "pages#view"
  get "policy" => "pages#policy"

Upvotes: 0

Views: 280

Answers (1)

Rob Di Marco
Rob Di Marco

Reputation: 44942

Take the quotes off of the root_path link.

<%= link_to "Document", root_path, "class" => 'navbar-brand' %>

Also, the link_to will create the a tag; you do not need it in the ERB

Upvotes: 1

Related Questions