Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy entire directory in Rails generator from templates

I am creating a rails generator and I want to copy an entire directory from templates. I am using FileUtils.cp_r and it works but the matter is that i need to precise the path of template directory from the rails app directory instead of just having the relative path like using copy_file : For example, I have

FileUtils.cp_r 'lib/generators/cms/templates/content_wrappers', 'app/views/content_wrappers'

It works fine but I would like just to use a relative path like in copy_file if possible. Any idea?

like image 603
Mika Andrianarijaona Avatar asked Sep 10 '11 05:09

Mika Andrianarijaona


1 Answers

The command to copy a whole directory in a generator method is simply:

def some_generator_method
  directory 'path_to_install_directory', 'path_to_source_directory'
end
like image 64
numbers1311407 Avatar answered Nov 11 '22 02:11

numbers1311407