开发者

request.raw_post trying to pull data from it

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

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."

B开发者_Go百科asically, I just to get "alex," where it says "keyword=alex." How can I do it?


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

Or alternatively, request.raw_post.split(/&/).grep(/keyword=/).first.split(/=/).last

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜