我是 Rails 开发的新手,但仍在尝试了解它的构建块。在运行这个简单的代码时,我收到以下错误
undefined method `home_home_path'
它来自这一行 <%= form_for(@homes) do |f| %> 在 .html.erb 文件中。这是我的完整代码,我做错了什么?
我有家庭控制器文件
def index
@homes = Home.all
end
def show
@home = Home.find(params[:id])
end
def new
@home = Home.new
end
def create
@home = Home.new(params[:home])
@home.save
end
Homes.rb 模型文件
class Home < ActiveRecord::Base
attr_accessible :email, :message, :name
end
意见/家园/index.html.erb
# this will show all the data
<% @homes.each do |home| %>
<%= home.name %><br />
<%= home.email %> <br />
<%= home.message %><br />
<% end %>
<br />
# this is a form where you will new records
<%= form_for(@homes) do |f| %>
<%= f.text_field :name %>
<%= f.text_field :email %>
<%= f.text_area :message %>
<%= f.submit %>
<% end %>