我在输入表单上的信息后遇到问题,我没有收到任何错误,但是当检查服务器的控制台时出现这个问题:
开始POST" / users" for :: 1 at 2017-06-22 18:33:54 -0600处理 by UsersController #create as HTML参数:{" utf8" =>"✓", " authenticity_token" = GT;" 9X / XZ0KJ + GqMaoJZTDlFq8WsHtfMUssqJ / DEr0JYCOSnv + hAoMPOW + GVOv8J5MBLp9DBAcmKeR6K2S5UhsX0lQ ==&#34 ;, "用户" => {" usuario" =>" Hschwartz"," nombres" =>" Herbert Mauricio&# 34 ;, " apellidos" =>" Schwartz Melara", "邮报" = GT;" mauricio_schwartzm@hotmail.com" ;, " nivel_autoridad" =>" Administrador"," password_digest" =>" [已过滤]", " password_confirmation" =>" [过滤]"},"提交" =>" Crear mi cuenta"} 未经许可的参数:: utf8,:authenticity_token,:user,:commit
(0.0ms)begin transaction(0.0ms)rollback transaction 在layouts / application中呈现users / new.html.erb呈现 布局/应用程序中的users / new.html.erb(9.5ms)已完成200 OK 在254ms(浏览次数:242.4ms | ActiveRecord:0.0ms)
如果您看到应用程序自动进行召回,我不知道为什么。
这是来自控制器文件的信息:
class UsersController < ApplicationController
skip_before_action :verify_authenticity_token
def index
@users = User.all
end
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
flash[:success] = "Usuario registrado exitosamente"
redirect_to @user
else
flash[:fail] = "Error al registrar usuario"
render 'new'
end
end
def show
end
private
def user_params
params.permit(:user)
end
end
如果你对我有所建议,我会表示同意。感谢。
答案 0 :(得分:2)
def user_params
params.require(:user).permit(:usuario, :nombres, ...)
end