System call from Ruby

后端 未结 2 665
萌比男神i
萌比男神i 2020-12-12 03:24

How can you call terminal calls from within Ruby?

Can i run \"rake db:migrate VERSION=....\" from within my Rails program?

2条回答
  •  无人及你
    2020-12-12 03:46

    Use "`" quotes:

    `rake db:migrate VERSION=....`
    

    or system

    system("rake db:migrate VERSION=....")
    

    Also you can use this notation:

    %x[rake db:migrate VERSION=...]
    

    Also see http://blog.jayfields.com/2006/06/ruby-kernel-system-exec-and-x.html

提交回复
热议问题