0
Udemy:训练营课程:部分:8讲座:122:节省数据:在“联系我们”页面我填写了信息,名称:test1,电子邮件:[email protected],评论: test1,作为一个测试,按下提交,但按钮不提交信息,并没有提供任何错误信息。我哪里错了?任何专家的建议?这里是我的代码:提交按钮
class ContactsController < ApplicationController
def new
@contact = Contact.new
end
def create
@contact = Contact.new(contact_params)
if @contact.save
flash[:success] = 'Message sent.'
redirect_to new_contact_path
else
flash[:danger] = 'Error occured, message has not been sent.'
redirect_to new_contact_path
end
end
end
private
def contact_params
params.require(:contact).permit(:name, :email, :comments)
end
<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>
@Theo工作的呢? – angkiki
angkiki - 我联合你的建议代码,但我得到这个错误: – Theo
@Theo最新错误?我看不到它 – angkiki