Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run a rails command command from a shell script?

Say I wanted to run 'User.all.each{|u| u.destroy}' from a shell script called killallusers.sh. How can I call Rails console commands from the shell or from an executable script?

like image 439
brojsimpson Avatar asked Jan 15 '23 11:01

brojsimpson


1 Answers

Either write it as a Rake task, or use Rails "runner".

Inside your shell script put the appropriate rake or runner command.

like image 194
the Tin Man Avatar answered Jan 19 '23 21:01

the Tin Man