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 directory error). I dunno exactly how to use Rails.public_path
(Rails.public_path/filename.csv
doesn't work) please help
相关问题
- Eager-loading association count with Arel (Rails 3
- How to specify memcache server to Rack::Session::M
- Why am I getting a “C compiler cannot create execu
- reference to a method?
- ruby 1.9 wrong file encoding on windows
相关文章
- Ruby using wrong version of openssl
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- “No explicit conversion of Symbol into String” for
- Rspec controller error expecting <“index”> but
- Factory_girl has_one relation with validates_prese
- Segmentation fault with ruby 2.0.0p247 leading to
- How to detect if an element exists in Watir
In Rails 4,
Rails.public_path
, likeRails.root
, returns a stdlib Pathname object, so you can also usejoin
with it:You have access to the
Rails.root
path, use it to get a pathYou'll possibly have to call
to_s
on it depending on how you want to use the result (as aPath
object or as a string).