开发者

how get the exact public path where a rails app lives

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜