How to specify the path of the public directory in a ruby on rails app?

后端 未结 2 2194
长情又很酷
长情又很酷 2021-02-20 04:45

I want to parse .csv file which is in public folder, I\'ve tried /../\'s, #{RAILS_ROOT}/public but with no success (No such file or direct

2条回答
  •  心在旅途
    2021-02-20 04:57

    In Rails 4, Rails.public_path, like Rails.root, returns a stdlib Pathname object, so you can also use join with it:

     Rails.public_path.join('filename.csv')
    

提交回复
热议问题