How to execute rails commandline statement inside our rails controller
eg: I need to execute this statement
$rails new test -d postgresql
from my rails controller
def index
/Code to execute the command line statement/
end
Hope am clear..
If you want to run shell commands inside controller just use "system"
Eg:
system "rails new test -d postgresql"
or else
exec "rails new test -d postgresql"
Use backticks to shell out, like this:
`rails new test -d postgresql`
It might be smarter to use a job queue for this.
To run command line statements inside controller, we can use system
command
system "cd {path_to_folder}; rails new test -d postgresql"
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