2014-06-25 91 views

回答

0

萬向變量獲得紅寶石params爲:

params 

這將從你可以在服務器日誌中看到的請求返回的參數的哈希值。

要訪問它,你只需要使用:

def set_params #use ruby notation for methods which is underscore and _ 
@parameters=params["key"] 
end 

注意,關鍵應該被定義,只要對HTML視圖傳入的參數包括編纂:UTF8和CSRF令牌。

如果你想獲得完整的請求:

def set_params 
    @request = request 
end 
0
class ApplicationController < ActionController::Base 
    before_filter :handle_params 

    def handle_params 
    my_param_key = params[:my_param_key] 
    end 
end 

希望這可以幫助別人開始代碼的紅寶石!

相關問題