Sathish
Sathish

Reputation: 4554

how get the exact public path where a rails app lives

Lets assume my RoR app lives at

http://case-1.example.com/part-1/sub-part-1/

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

Upvotes: 0

Views: 1292

Answers (3)

Pravin
Pravin

Reputation: 6662

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..

Upvotes: 5

Pravin
Pravin

Reputation: 6662

For rails 3+ Use :

@app_root_path = Rails.root

For rails < 3 Use

@app_root_path = RAILS_ROOT

Upvotes: 3

Anubhaw
Anubhaw

Reputation: 6068

You can get the path by following:-

@rails_app_path = RAILS_ROOT

Thanks......

Upvotes: 1

Related Questions