The Error I Get参数是丢失或为空值:subscribeduser
我得到的错误,当我试图通过转换params.require(:subscribeduser).permit(:email)
到params.permit(:email)
创建一个新的subscribeduser
,我有点“固定”的,但我觉得不舒服关于它。我如何正确摆脱这个错误?
SubscribedusersController
class SubscribedusersController < ApplicationController
before_action :set_subscribeduser, only: [:show, :edit, :update, :destroy]
def index
@subscribedusers = Subscribeduser.all
end
def new
@subscribeduser = Subscribeduser.new
end
def create
@subscribeduser = Subscribeduser.new(subscribeduser_params)
respond_to do |format|
if @subscribeduser.save
RegistrationMailer.thankyou_mail(@subscribeduser).deliver_now
format.html { redirect_to @subscribeduser, notice: 'Subscribeduser was successfully created.' }
format.json { render :show, status: :created, location: @subscribeduser }
else
format.html { render :new }
format.json { render json: @subscribeduser.errors, status: :unprocessable_entity }
end
end
end
def subscribeduser_params
params.require(:subscribeduser).permit(:email)
end
end
这是Subscribeduser形式
<%= form_for(subscribeduser,:html => {:id => 'signup-form' }) do |f| %>
<div class="field">
<%= f.text_field :email, :name =>"email", :id => "signup-form", "placeholder" => "Email Address" %>
</div>
<div class="actions">
<%= f.submit "Sign Up!" %>
</div>
<% end %>
阅读,请发表您的看法,以及而params您得到的控制器在创建对象 –
上面清清楚楚地写着:subscribeduser参数是缺少这样的东西是不对您的形式 –
你可以看看日志并找到打印参数的行吗?你可以把它添加到问题? –