I am deploying my Rails app to Digital Ocean.
I need to run a custom ruby script via the Rails console (or even on a job queue) and in some cases I want it to create a file and store it within my config directory.
Specifically, this is what the setup looks like:
Money.default_bank = MoneyOXR::Bank.new(
app_id: ENV["APP_ID"],
cache_path: 'config/oxr.json',
max_age: 86400
)
So, what needs to happen is whenever it runs it needs to create the config/oxr.json.
However, when I run it, this is what happens:
Errno::EACCES: Permission denied @ rb_sysopen - config/oxr.json
Right now, I am just running it as MyScript.run at the command line in Rails console.
How do I do this?
You need to give the necessary folder permissions to
create/writea file. You can do that by:This gives write permission to app
configfolder.If you want to give permissions to a certain user then:
Edited by OP
What also works is:
sudo chmod 777 oxr.json