I need to move a folder from a plugin to the main app/views. I guess using rake to do this with the following command is the easiest way:
require 'fileutils'
FileUtils.mv('/vendor/plugins/easy_addresses/lib/app/views', '/app/views/')
I'm just not sure where to tell script where to look and where to place the folder.
The file I want to move is in the following location: `vender/plugins/easy_addresses/lib/app/views/easy_addresses
easy_ addresses is the name of the folder in views
that I want to move to my_app/app/views/
FileUtils.mv('/source/', '/destination/')
There is a constant which has the rails root, just prepend it to your pathes:
File.join(RAILS_ROOT, "app", "views")
Here RAILS_ROOT
holds the location "where to look", and using File.join
on the path components takes care of concatenating the components using the right path separator suitable for the used system.
In the result the above method call gives you the complete absolute path to "app/views" in your application.
Edit:
In Rails >= 3 you can use Rails.root.join('app', 'views')
.
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