0
聲明:我對Ruby + rails非常陌生。我不確定這是否是一個錯誤,但我的params
變量總是顯示爲空。我正在研究一個龐大而陌生的代碼庫,所以我不確定它是否有其他干擾或我自己的代碼;但是任何建議都會受到歡迎。Params未保存在欄中
在我的路線文件中,我有match '/proxy_request/:number/:ref' => 'proxies#show', via: :get
- 我的印象是,這將存儲:number
和:ref
變量在params
。但是,當我的proxies#show
函數運行(下)時,params是一個空的散列。
萬一它可能是別的干擾params
,是否有另一種方式通過:number
和:ref
到proxies#show
?
class ProxiesController < ApplicationController
include Service
skip_before_action :restrict_access!
def show
binding.pry #params is null here
data = { date: Adapter.staging_date.get(params[:number], params[:ref])}
render json: data, content_type: "application/javascript", callback: @_request.env["QUERY_STRING"].match(/jQuery\d*_\d*/)
end
end
所以你使用看起來像'/ proxy_request/X/y'糾正其中'x'是一個路線正在訪問這樣的:數量和' y'是:ref?這就是這些變量如何以參數結束。 – engineersmnky
你如何稱此路線? –
你是對的。再次檢查您的鏈接。 – Nathan