ruby - Rails generating a new directory multiple levels deep -
this question has answer here:
i have built little app generates excel document. trying make directory stick in. these documents built differently depending on @agency
people select. made method return path since path used in few places.
def reportsheet_dir file_path = "#{rails.root}/public/reportsheets/#{@agency.downcase.gsub("_","")}" end
at beginning of method creates document have method supposedly builds directories doest seem working
dir.mkdir(reportsheet_dir) unless file.exists?(reportsheet_dir)
i keep getting. ,
errno::enoent @ /addons/agency_report_builders no such file or directory -/users/fortknokx/work/toolkit/public/reportsheets/empowerlogicbuilder
i think because multiple levels deep?? since public/reportsheets/agency_name/file_name
has made. go , make folders make dir each time because new agencies made @ time. possible?
have @ fileutils.mkdir_p()
http://ruby-doc.org/stdlib-1.9.3/libdoc/fileutils/rdoc/fileutils.html#method-c-mkdir_p
it recursively create non-existent directories. dir.mkdir
not.
Comments
Post a Comment