Lets assume my RoR app lives at
假设我的RoR应用程序存在于
In a view file, how can I get that path?
在视图文件中,如何获取该路径?
3 个解决方案
#1
5
To get full url of the current page you can use
要获取当前页面的完整URL,您可以使用
current_url = request.request_uri
This will return you full url, you can then gsub http or https. Hope this was you were looking for.
这将返回您的完整网址,然后您可以gsub http或https。希望这是你在找。
Thanks..
#2
3
For rails 3+ Use :
对于rails 3+使用:
@app_root_path = Rails.root
For rails < 3 Use
对于rails <3使用
@app_root_path = RAILS_ROOT
#3
1
You can get the path by following:-
您可以通过以下方式获取路径: -
@rails_app_path = RAILS_ROOT
Thanks......
#1
5
To get full url of the current page you can use
要获取当前页面的完整URL,您可以使用
current_url = request.request_uri
This will return you full url, you can then gsub http or https. Hope this was you were looking for.
这将返回您的完整网址,然后您可以gsub http或https。希望这是你在找。
Thanks..
#2
3
For rails 3+ Use :
对于rails 3+使用:
@app_root_path = Rails.root
For rails < 3 Use
对于rails <3使用
@app_root_path = RAILS_ROOT
#3
1
You can get the path by following:-
您可以通过以下方式获取路径: -
@rails_app_path = RAILS_ROOT
Thanks......