I am trying to create a directory in Rails with the following code:
File.makedirs ‘/folder/subfolder/’
However, I get the error “undefined method `makedirs’ for File:Class”.
Has makedirs been deprecated to something else?
Thanks,
peter
I am trying to create a directory in Rails with the following code:
File.makedirs ‘/folder/subfolder/’
However, I get the error “undefined method `makedirs’ for File:Class”.
Has makedirs been deprecated to something else?
Thanks,
peter
Peter M. schrieb:
I am trying to create a directory in Rails with the following code:
File.makedirs ‘/folder/subfolder/’
However, I get the error “undefined method `makedirs’ for File:Class”.
Has makedirs been deprecated to something else?Thanks,
peter
makedir is a method defined in ftools (see
class File - RDoc Documentation). Therefore - add
require ‘ftools’
if you want to use this method.
Or even better use the corresponding method being defined in “FileUtils”
module.
BR Phil
Phil M. wrote:
require ‘ftools’
ah, of course. Thanks for helping a neub Phil
On Oct 1, 2007, at 23:51 , Peter M. wrote:
Phil M. wrote:
require ‘ftools’
ah, of course. Thanks for helping a neub Phil
FileUtils is the preferred way now. ftools.rb says:
FileUtils contains all or nearly all the same functionality and
more, and
is a recommended option over ftools
See the method descriptions below, and consider using FileUtils
as it is
more comprehensive.
FileUtils.mkdir_p makes directories recursively.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs