开发者

request.raw_post trying to pull data from it

开发者 https://www.devze.com 2023-01-09 06:04 出处:网络
def search_results @keyword = request.raw_post @tutors = Tutors.find(:all,:conditions => [\"first_name LIKE ?\", \'%\' + \"raul\" + \'%\'])
  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

精彩评论

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