How to execute a Ruby script in Terminal?

前端 未结 9 1628
南笙
南笙 2020-12-04 06:15

I\'ve set everything up that I need on my Mac (Ruby, Rails, Homebrew, Git, etc), and I\'ve even written a small program. Now, how do I execute it in Terminal? I wrote the pr

9条回答
  •  不知归路
    2020-12-04 06:55

    In case someone is trying to run a script in a RAILS environment, rails provide a runner to execute scripts in rails context via

    rails runner my_script.rb

    More details here: https://guides.rubyonrails.org/command_line.html#rails-runner

提交回复
热议问题