Is it possible to spawn rails console from nodejs and then execute the script in rails console ?
const { spawn } = require('child_process');
const child_process = spawn('rails c');
child_process.stdout.on('data', function (data) {
console.log('stdout', data.toString());
});
child_process.stderr.on('data', function (data) {
console.log('stderr', data);
});
child_process.on('close', function (code) {
console.log('close', code);
});
Upon opening the console, i wanted to execute this script in the rails console
user_id = 1624522827
Sharding.get_shard(user_id) do
account = UserList::User.find(user_id).make_user
end
How to achieve this in nodejs. My intention is to create a cli that runs script inside rails console.