我的 Rails 应用程序中有一个错误,告诉我索引方法未定义。我创建了一个如此简单的表单,仅用于使用(新方法页面)插入数据,但由于某种原因它现在无法正常工作
class PeoplesController < ApplicationController
def index
end
def new
@people = People.new
end
def create
@people = People.new(params[:@people])
if @people.save
redirect_to new_people_path
end
end
end
# new.html.haml
<h2>Hello there!</h2>
<hr >
<%= form_for @people do |f| %>
FirstName:<%= f.text_field :first %><br />
LastName:<%= f.text_field :last %><br />
<%= f.submit %>
<% end %>
这是错误代码:
NoMethodError in Peoples#new
Showing /Users/kasim/Desktop/form/app/views/peoples/new.html.erb where line #3 raised:
undefined method `people_index_path' for #<#<Class:0x007fa33da58d58>:0x007fa34031c578>
Extracted source (around line #3):
1: <h2>Hello there!</h2>
2: <hr >
3: <%= form_for @people do |f| %>
4: FirstName:<%= f.text_field :first %><br />
5: LastName:<%= f.text_field :last %><br />
6: <%= f.submit %>