简体   繁体   English

检查在Rails控制器上的ruby中收到的表单数据

[英]checking the form data received in ruby on rails controller

I want to check the form data received from the form in ruby on rails controller. 我想检查从Rails控制器中的ruby表单接收到的表单数据。

I tried this but nothing is shown: 我试过了,但是什么也没显示:

@user.to_yaml

where @user is the form name( <%=form_for @user ) 其中@user是表单名称( <%=form_for @user

the data sent by a form is stored in the params hash (see this question for more information). 表单发送的数据存储在params哈希中(有关更多信息,请参阅此问题 )。

also, in development, just put a raise in your controller action to show an error page with all request parameters displayed. 同样,在开发中,只需在控制器操作中raise即可显示显示所有请求参数的错误页面。

The above answer is correct. 上面的答案是正确的。 but will like to change something 但想改变一些东西

all the details are stored in params only

and it will be better to show those in flash by doing flash.notice = params 并且最好通过执行flash.notice = params在Flash中显示这些内容

as it will not effect the working of app 因为这不会影响应用程序的运行

为什么不在控制台上签出服务器日志或使用调试器gem来跟踪请求所沿的参数和文件...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM