Нет совпадений маршрута с контроллером show - scaffold сгенерированный код

Я запустил приложение Rails с помощью scaffold. Приложение связывает людей с учреждениями. Когда я перехожу на

http: // localhost: 3000 / people

, я получаю следующую ошибку:

No route matches {:controller=>"people", :action=>"show", :id=>#

(и так далее)

Если я удалю все ячейки "link_to" в созданном шаблоном table, страница загружается нормально. Эта ошибка возникает для всех файлов index.html.erb в моем приложении.

Вот мои люди / index.html.erb

Listing people

<% @people.each do |person| %> <% end %>
<%= person.name %> <%= link_to 'Show', person %> <%= link_to 'Edit', edit_person_path(person) %> <%= link_to 'Destroy', person, :confirm => 'Are you sure?', :method => :delete %>

<%= link_to 'New Person', new_person_path %>

И начало моих контроллеров / людей. rb

class PeopleController < ApplicationController
  # GET /people
  # GET /people.xml
  def index
    @people = Person.all(:order => "year_grad, name")

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @people }
    end
  end

  # GET /people/1
  # GET /people/1.xml
  def show
    @person = Person.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @person }
    end
  end

и результаты 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"}

и миграции для людей

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

, а вот мой файл routes.rb (без комментариев, которые автоматически генерирует scaffolding):

IHiring::Application.routes.draw do
  resources :ranks, :departments, :institutions, :schools, :people

  get "home/index"
  root :to => "home#index"

end

Имеет ли это какое-то отношение к установка другого primary_key для таблицы? Я не уверен, проблема ли это в модели или маршрутах. Или что-то, о чем я не подумал. Я перезапустил свой сервер rails после сборки лесов.

6
задан Libby 30 January 2011 в 19:34
поделиться