Is it possible to create a ruby script that can execute rails commands?
Like:
rails_start.rb:
Class RailsStart
#Start rails server
rails server
end
asked Jan 28, 2013 at 19:12
Rails beginner
14.5k35 gold badges141 silver badges260 bronze badges
-
Why would you want to do that?Sergio Tulentsev– Sergio Tulentsev2013年01月28日 19:15:54 +00:00Commented Jan 28, 2013 at 19:15
2 Answers 2
You can always shell out.
system('rails server')
or
`rails server` # backticks
answered Jan 28, 2013 at 19:17
Sergio Tulentsev
231k43 gold badges381 silver badges373 bronze badges
Sign up to request clarification or add additional context in comments.
3 Comments
Rails beginner
Is it possible to define path to rails? So you can fire up multiple rails servers for apps. And where did you find this documentation for system?
Sergio Tulentsev
It's Kernel#system. No, you can't fire multiple servers this way. Unless you fork or multi-thread. See also Dir#chdir
Rails beginner
The easiest way is to put backticks around the command:
`rails server`
But what are you trying to do?
answered Jan 28, 2013 at 19:17
Zach Kemp
11.9k1 gold badge35 silver badges47 bronze badges
Comments
lang-rb