0

So I'm trying to get my "path to an uploaded archive.zip"

in my model:

def path_to_upload "#{self.folder.path}" end 

gives me:

/Users/jweber/Sites/Proofer_v2/public/assets/415/Archive.zip 

but what I want is,

/Users/jweber/Sites/Proofer_v2/public/assets/415/ 

and I've produced it with:

def path_to_upload "#{self.folder.path.split("/").reverse.drop(1).reverse.join("/")}/" end 

but that looks crappy, Do you know a "beautiful" way to return the desired output? I'd even settle for less than hideous.

1 Answer 1

1

How about

File.dirname(self.folder.path) + '/' #=> "/Users/jweber/Sites/Proofer_v2/public/assets/415/" 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.