I launched the Rails application using scaffold. The app connects people with institutions. When i go to
http: // localhost: 3000 / people
I get the following error:
No route matches {:controller=>"people", :action=>"show", :id=>
(etc.)
If I delete all the "link_to" cells in the table created by the scaffold, the page loads just fine. This error occurs for all index.html.erb files in my application.
Here are my people /index.html.erb
<h1>Listing people</h1> <table> <tr> <th></th> <th></th> <th></th> <th></th> </tr> <% @people.each do |person| %> <tr> <td><%= person.name %></td> <td><%= link_to 'Show', person %></td> <td><%= link_to 'Edit', edit_person_path(person) %></td> <td><%= link_to 'Destroy', person, :confirm => 'Are you sure?', :method => :delete %></td> </tr> <% end %> </table> <br /> <%= link_to 'New Person', new_person_path %>
And the beginning of my controllers /people.rb
class PeopleController < ApplicationController
and the results of rake routes
people GET /people(.:format) {:controller=>"people", :action=>"index"} POST /people(.:format) {:controller=>"people", :action=>"create"} new_person GET /people/new(.:format) {:controller=>"people", :action=>"new"} edit_person GET /people/:id/edit(.:format) {:controller=>"people", :action=>"edit"} person GET /people/:id(.:format) {:controller=>"people", :action=>"show"} PUT /people/:id(.:format) {:controller=>"people", :action=>"update"} DELETE /people/:id(.:format) {:controller=>"people", :action=>"destroy"} home_index GET /home/index(.:format) {:controller=>"home", :action=>"index"} root /(.:format) {:controller=>"home", :action=>"index"}
and migration for people
class CreatePeople < ActiveRecord::Migration def self.up create_table :people, :id => false, :primary_key => :pid do |t| t.integer :pid, :null =>false t.string :name t.string :degree t.integer :phd_area t.string :thesis_title t.integer :year_grad t.integer :instid_phd t.integer :year_hired t.integer :instid_hired t.integer :schoolid_hired t.integer :deptid_hired t.string :email t.string :notes t.integer :hire_rankid t.integer :tenure_track t.integer :prev_instid t.integer :prev_rankid end end def self.down drop_table :people end end
and here is my route.rb file (minus the commented lines that scaffolding automatically generates):
IHiring::Application.routes.draw do resources :ranks, :departments, :institutions, :schools, :people get "home/index" root :to => "home#index" end
Does it have anything to do with setting another primary_key for the table? I am not sure if this is a model or route problem. Or something that I didnβt think about. I restarted the rails server after scaffolding.