【发布时间】:2014-03-12 11:41:43
【问题描述】:
我从普通的 html 文件访问 localhost。 html代码是
<!DOCTYPE html>
<html>
<body>
<div id="deal">
<a href="http://localhost:3000">Home</a>
</div>
</body>
</html>
我的文件路径是
file:///home/selva/Desktop/test.html#deal
当我点击Home 链接时,我需要将#deal 加入到rails 项目中。所以我用这个方法URI(request.referer).path
require 'uri'
class RefUrlAuthentication < ::Devise::Strategies::Authenticatable
def valid?
puts "PARAMS: #{URI(request.referer).path}"
end
end
我已经尝试过request.referer,但没有成功。
这里出现这个错误
ArgumentError (bad argument (expected URI object or URI string)):
lib/custom_authentication.rb:100:in valid?'
当我使用URI(request.referer).path时出现此错误
我无法弄清楚这段代码有什么问题。如何忽略此错误并获取 url 文件 url.谢谢你的时间。
【问题讨论】:
标签: ruby-on-rails ruby uri