【发布时间】:2016-01-10 19:35:10
【问题描述】:
当我尝试保存时,我得到了错误。
参数丢失或值为空:帮助
我的错误在哪里?我第一次看到这个错误
我的application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def authenticate_admin_user!
authenticate_user!
redirect_to root_path unless current_user.admin?
end
def help_request
@help = Help.new(help_params)
if @help.save
redirect_to root_path
else
#
end
end
private
def help_params
params.require(:help).permit(:name, :email, :messages)
end
end
和我的部分_help_request.html.slim
div id="help_request"
h1 Help form
hr
= form_for Help.new, as: :post, url: help_request_path do |f|
= f.label :name
br
br
= f.text_field :name, class: 'form-control',
placeholder: 'your name'
= f.label :email
br
br
= f.text_field :email, class: 'form-control',
placeholder: 'your email'
= f.label :messages
br
br
= f.text_area :messages, class: 'form-control',
placeholder: 'your message'
br
br
= f.submit 'Send', class: 'btn btn-primary'
【问题讨论】:
标签: ruby-on-rails ruby model params