Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 702
Vincent Avatar asked Jul 24 '10 01:07

Vincent


1 Answers

Rails.public_path should provide you the public path

like image 142
William Avatar answered Sep 27 '22 21:09

William