ruby on rails - How to split the file path of my head point gets changes? -
i want split file path according occurance of head point in file path.
case 1:
puts fileutils.pwd() output:
"/home/myhome/bigproject/now_with_bugs_fixed/subfolder/" my project head bigproject. want split file path head point bigproject , want result as:
/bigproject/now_with_bugs_fixed/subfolder/ case 2:
puts fileutils.pwd() output:
"/home/data/cloud/vz-hadoop/bigproject/now_with_bugs_fixed/subfolder/" now project head again bigprojectbut there little change in path.i want split file path head point bigproject , want result same in case 1:
/bigproject/now_with_bugs_fixed/subfolder/ i want in ruby language.please don't use index numbers.
> s = fileutils.pwd > s[s.index('/bigproject')..-1] => "/bigproject/now_with_bugs_fixed/subfolder/" or split:
> s.split('myhome')[1] => "/bigproject/now_with_bugs_fixed/subfolder/" (or ton of other ways.)
that said, sure want do?
if you're trying dig rails app's directory hierarchy, isn't approach i'd take, instead going along rails root directory path per comment.