request.raw_post 试图从中提取数据 [英] request.raw_post trying to pull data from it

查看:49
本文介绍了request.raw_post 试图从中提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  def search_results
       @keyword = request.raw_post
       @tutors = Tutors.find(:all,:conditions => ["first_name LIKE ?", '%' + "raul" + '%'])    
  end

我正在尝试从 request.raw_post 中获取一些信息,但它给了我这么长的字符串:authenticity_token=HxxkPMpSr0kHZOVZIYbpMti217BTeUa5G2vX8zbs8ig%3D&keyword=alex&kenZ7HpHpX8DPIHpX8DPIHpX8DPIHpX8DPIHpZ8HpX8DPIHpSr0kHZOVZIYbpMti217BTeUa5G2

I am trying to get some information out of request.raw_post, but it is giving me this long string: "authenticity_token=HxxkPMpSr0kHZOVZIYbpMti217BTeUa5G2vX8zbs8ig%3D&keyword=alex&authenticity_token=HxxkPMpSr0kHZOVZIYbpMti217BTeUa5G2vX8zbs8ig%3D."

基本上,我只是想得到alex",它说keyword=alex".我该怎么做?

Basically, I just to get "alex," where it says "keyword=alex." How can I do it?

推荐答案

如果你想要那个值,我建议使用 params[:keyword].

If you want that value, I would suggest using params[:keyword].

或者,request.raw_post.split(/&/).grep(/keyword=/).first.split(/=/).last

这篇关于request.raw_post 试图从中提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆