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

我試圖得到一些信息出來的request.raw_post,但它給我這個長的字符串中提取數據:「authenticity_token = HxxkPMpSr0kHZOVZIYbpMti217BTeUa5G2vX8zbs8ig%3D &關鍵字=亞歷克斯& authenticity_token = HxxkPMpSr0kHZOVZIYbpMti217BTeUa5G2vX8zbs8ig% 3D「。request.raw_post試圖從它

基本上,我只是爲了獲得「亞歷克斯」,它說:「關鍵字=亞歷克斯。」我該怎麼做?

回答

1

如果你想要的價值,我會建議PARAMS [:關鍵字]。

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

+0

是啊,這正是我所做的。 – Alex 2010-07-29 21:52:05