【发布时间】:2015-11-01 17:46:03
【问题描述】:
大家好...我正在学习 Ruby on Rail,但我不知道这个页面上发生了什么,这是我的错误:
联系人中的 NoMethodError#new 显示 /home/ubuntu/workspace/simplecodecasts_saas/app/views/contacts/new.html.erb 其中第 7 行提出: # 的未定义方法“名称”
这是我的 new.html.erb
<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>
这是我的路线
Rails.application.routes.draw do
resources :contacts
get '/about' => 'pages#about'
root 'pages#home'
还有我的 contacts_controller.rb
class ContactsController < ApplicationController
def new
@contact = Contact.new
end
def create
end
end
出了什么问题?
完整的错误屏幕 screen
【问题讨论】:
-
这意味着您的
Contact表在数据库中没有name列。 -
这是我的联系表
-
这是我的联系人表类 CreateContacts
-
你跑
rake db:migrate了吗? -
你能粘贴完整的错误吗?
标签: ruby-on-rails ruby ruby-on-rails-3 nomethoderror