我正在尝试在我的控制器上创建一个申请人我可以在applicant_params方法中看到params,并且可以使用pry访问哈希以验证哈希是否正确。当create方法然后触发所有@applicant值都是nil?我必须在这里错过一些基本的东西吗?
def applicant_params
params.require(:applicant).permit(
:first_name, :last_name, :email_address, :contact_number,
binding.pry
end
端
def create
@applicant = Applicant.new(applicant_params)
binding.pry
respond_to do |format|
if @applicant.save
format.html { redirect_to @applicant, notice: 'Applicant was successfully created.' }
format.json { render action: 'show', status: :created, location: @applicant }
else
binding.pry
format.html { render action: 'new' }
format.json { render json: @applicant.errors, status: :unprocessable_entity }
end
end
end
答案 0 :(得分:0)
没有binding.pry
,它仍会失败吗?该调用返回nil并且会搞砸......