0

I am new to rails & I am trying to achieve the bellow scenario

Lets say I have a Model called Sites with Field domain name. & created an entry with domain name "example.com" & It stored to database.

So Now what I am trying to do is after save it will trigger a command to create a Nginx server block with the given Domain name "example.com" right from rails app.

I know Little bit of shell scripting but don't know how I can run the script from rails based on the data saved on rails db.

Any guideline or Code snippets would be very helpful,

Thanks

1 Answers1

0

Technically you can run any script code from ruby, the problem I see here is that to update nginx block you need to execute the script as root, and this would be very a bad idea to do directly from your rail app.

How to call shell commands from Ruby

IgnazioC
  • 4,554
  • 4
  • 33
  • 46