0
我的導軌應用程序中有一個錯誤,告訴我索引方法未定義。 我創建了一個這樣簡單的表格只是使用(新方法頁)將數據僅 但它不是出於某種原因我的導軌應用程序中的簡單錯誤
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 %>
new.html.erb代碼在控制器代碼下面! – user1778530
確切的錯誤是什麼? – pjam
rails慣例是爲模型使用單數名稱,例如'Person'。 –