Forum: Ruby Directory within directorry??

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Saurabh P. (Guest)
on 2009-03-18 08:26
Hi All,

I want to create a directory, i used command:

Dir.mkdir("#{RAILS_ROOT}/public/public1/public2/public3")

but its not working. don't know the reason.
So i tried for:

Dir.mkdir("#{RAILS_ROOT}/public/public1")
Dir.mkdir("#{RAILS_ROOT}/public/public1/public2")
Dir.mkdir("#{RAILS_ROOT}/public/public1/public2/public3")

and it worked.

Can the code be minimized?
Please suggest me, can the three lined code be made one lined?

Thanks
Saurabh
Heesob P. (Guest)
on 2009-03-18 08:32
(Received via mailing list)
Hi,

2009/3/18 Saurabh P. <removed_email_address@domain.invalid>:
> Dir.mkdir("#{RAILS_ROOT}/public/public1/public2")
> Dir.mkdir("#{RAILS_ROOT}/public/public1/public2/public3")
>
> and it worked.
>
> Can the code be minimized?
> Please suggest me, can the three lined code be made one lined?
>
require 'fileutils'
FileUtils.mkdir_p "#{RAILS_ROOT}/public/public1/public2/public3"


Regards,

Park H.
Clifford H. (Guest)
on 2009-03-18 08:40
(Received via mailing list)
Saurabh P. wrote:
> I want to create a directory, i used command:
> Dir.mkdir("#{RAILS_ROOT}/public/public1/public2/public3")
> Can the code be minimized?

require 'fileutils'
FileUtils::mkpath("#{RAILS_ROOT}/public/public1/public2/public3")
This topic is locked and can not be replied to.