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

Let's 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 a shell or from a script executable?

+3
ruby bash ruby-on-rails sh ruby-on-rails-3.2


source to share


1 answer


Either write as a Rake task or use a Rails runner .



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

+6


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics