开发者

how get the exact public path where a rails app lives

开发者 https://www.devze.com 2023-02-04 00:39 出处:网络
Lets assume my RoR app lives at http开发者_StackOverflow社区://case-1.example.com/part-1/sub-part-1/

Lets assume my RoR app lives at

http开发者_StackOverflow社区://case-1.example.com/part-1/sub-part-1/

In a view file, how can I get that path?


To get full url of the current page you can use

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.

Thanks..


For rails 3+ Use :

@app_root_path = Rails.root

For rails < 3 Use

@app_root_path = RAILS_ROOT


You can get the path by following:-

@rails_app_path = RAILS_ROOT

Thanks......

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号