Reputation: 3
So I've just started to learn ruby on rails but ran into some issues while linking pages together. The error occurred after I was trying to get localhost:3000 to be my home page instead localhost:3000/home/index
Instead of my site I got the error:
undefined local variable or method `portal_pages_updates_path' for #<#:0x2d37ff8>
and highlighting my footer links as the issue.
</small>
<nav>
<ul>
<li><%= link_to "Updates",portal_pages_updates_path %></li>
<li><%= link_to "Contact", portal_pages_contact_path %></li>
</ul>
</nav>
This is my Routes.rb that I modified which game me the error
GameProject::Application.routes.draw do
root :to =>'home#index'
match '/contact', to: 'portal_pages#contact', via: 'get'
match '/updates', to: 'portal_pages#updates', via: 'get'
Upvotes: 0
Views: 35
Reputation: 29349
In order to use named routes for custom action, you have to specify it in your routes.rb
match '/contact', to: 'portal_pages#contact', via: 'get', as: "portal_pages_contact"
match '/updates', to: 'portal_pages#updates', via: 'get', as: "portal_pages_updates"
Upvotes: 1