System call from Ruby

后端 未结 2 659
萌比男神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

    0 讨论(0)
  • 2020-12-12 03:54

    This should give you the info you need: http://blog.jayfields.com/2006/06/ruby-kernel-system-exec-and-x.html

    0 讨论(0)
提交回复
热议问题