Nadiya
Nadiya

Reputation: 1527

Can't create a file via shell code in Rails app

In my ruby script there's a line to create a new file:

File.open("/var/test.json", "w")

If I call this script from console the file is created. But when I execute shell code in Rails app %x( ruby script.rb ) the file isn't created. Is there any reason for it? Should I require or include something additional?

Upvotes: 1

Views: 36

Answers (1)

rderoldan1
rderoldan1

Reputation: 4098

Maybe you are not sending the right path to the script, asume you have script.rb inside lib:

%x( ruby #{Rails.root.join('lib', 'script.rb')} )

I think you need to send the full path, but I need more information to know the exact error.

Upvotes: 2

Related Questions