简体   繁体   中英

Getting absolute path to the file inside the public folder in Rails

What is the best way to get absolute path to the file inside the public folder in controller? Is there a predefined Rails variable that holds absolute path to the public folder?

Currently I'm using File.expand_path('../../../public', __FILE__) , but I'm sure there's a nicer way of doing this.

Rails.public_path应该为您提供公共路径

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM