【发布时间】:2016-01-10 16:06:12
【问题描述】:
我已经经历了几个小时,我似乎无法找到问题所在。我在 rails 中做了一个简单的联系人表格,这是我正在遵循的教程,所以请耐心等待。我收到以下错误消息:
# 的未定义方法“名称”
我的数据库/迁移文件中有这个:
class CreateContacts < ActiveRecord::Migration
def change
create_table :contacts do |t|
t.string :name
t.string :email
t.text :comments
t.timestamps
end
end
end
这在我的contacts_controller.rb 文件中:
class ContactsController < ApplicationController
def new
@contact = Contact.new
end
def create
end
end
这是在我的pages_controller.rb:
class PagesController < ApplicationController
def homepage
end
def about
end
end
这是我的html:
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="well">
<%= form_for @contact do |f| %>
<div class="form-group">
<%= f.label :name %>
<%= f.text_field :name, class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :comments %>
<%= f.text_area :comments, class: 'form-control' %>
</div>
<%= f.submit 'Submit', class: 'btn btn-default' %>
<% end %>
</div>
</div>
</div>
【问题讨论】:
-
你在学习哪个教程?
-
@RichPeck 这是我购买的一门名为 CoderManual 的课程
标签: ruby-on-rails ruby methods undefined