开发者

From an action, get a post variable, output to page, then halt execution

开发者 https://www.devze.com 2023-01-17 01:27 出处:网络
Is it possible to grab a post variable in a action, output it to the screen, and then halt execution?

Is it possible to grab a post variable in a action, output it to the screen, and then halt execution?

in asp.net I would do:

Response.Write (Request.Form["blah"]);
Resp开发者_运维技巧onse.End();


In addition to suggestions already mentioned, you can raise exceptions:

raise params[:blah]
raise params.inspect
raise params.to_yaml
# ...and so on

In this case, you can even just do raise without specifying anything. Rails will by default print out all params as part of its exception message screen.


puts params[:blah]
abort


If you are trying to send it back to the browser (output to screen?) to debug, you can drop this line in your action. The "return" will prevent a double render error. But this will not halt execution of after_filter if you have one.

  render :text=> params[:blah] and return
0

精彩评论

暂无评论...
验证码 换一张
取 消