FOLDER PERMISSION IN RAILS
When we deploy the project on server, Then sometimes the public folder want's the permission. For that we can give the permission from Rails.
Creating dir or folder with permission ;-
FileUtils.mkdir 'csv_imported', :mode => 0777
Give the permission of created dir or folder :-
FileUtils.chmod(0777, "csv_imported")
Delete the Directory:-
FileUtils.rm_rf('csv_imported' )
Give the permission of particular files :-
File.chmod(0777, path)
Join the folder with root directory :-
csv_folder = Rails.root.join('csv_imported' )
Create random csv files :-
csv_name = SecureRandom.urlsafe_base64 + ".csv"
Rename the file :-
File.rename("rohit.csv", csv_folder + csv_name )
You can also refer :-
https://www.ruby-forum.com/top
Comments