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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With