0

at the moment, my nav-bar content looks like this:

<li><%= link_to "Portfolio", projects_path, :class => "header" %></li>
<li><%= link_to "Articles", posts_path, :class => "header" %></li>
<li><%= link_to 'Contact',  contact_path, :class => "header" %></li>

The first two links work fine, but the last one doesn't. How do I refer correcty? The contact page is just a simple, static page (no projects, or blogs that get pushed).

This my routes.rb

Rails.application.routes.draw do
  resources :contact
  get 'contact/index'
  resources :posts
  resources :projects
  get 'welcome/index'
  root 'welcome#index'
end

And this is the controller

class ContactController < ApplicationController
    def index
    end
end

If I take a look at the rake routes, I am get this:

contact_index GET    /contact(.:format)           contact#index
              POST   /contact(.:format)           contact#create
  new_contact GET    /contact/new(.:format)       contact#new
 edit_contact GET    /contact/:id/edit(.:format)  contact#edit
      contact GET    /contact/:id(.:format)       contact#show
              PATCH  /contact/:id(.:format)       contact#update
              PUT    /contact/:id(.:format)       contact#update
              DELETE /contact/:id(.:format)       contact#destroy
              GET    /contact/index(.:format)     contact#index

I am new at ruby and I am looking forward to help. Thanks already in advance!

2 Answers2

2

Replace your third line with following line:

<li><%= link_to 'Contact', contact_index_path, class: "header" %></li>
Toribio
  • 3,963
  • 3
  • 34
  • 48
Rajnik
  • 83
  • 9
0

Get rid of get 'contact/index' from your routes file and try.

You already have a path for index of contact, when you added resources :contact

Kumar
  • 3,116
  • 2
  • 16
  • 24