views:

28

answers:

1

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.

+1  A: 

Rails.public_path should provide you the public path

William
Great, thanks! I also found "#{RAILS_ROOT}/public", but your method is way nicer.
Vincent