如何在rails控制器中获取Request Referer

时间:2015-03-11 06:00:55

标签: ruby-on-rails http header request referer

def total
   puts requeset.referrer
   transactions = UTransaction.all
   render json: amount(transactions)
end

我在控制台中遇到以下错误

Completed 500 Internal Server Error in 38ms

NameError (undefined local variable or method `requeset' for #<Api::V1::Admin::UTransactionsController:0x007f98d49539d0>)

1 个答案:

答案 0 :(得分:3)

您使用正确的方法referrer,但需要在request对象上调用它。

puts requeset.referrer

应该是

puts request.referrer