0

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
1
  • Why would you want to do that? Commented Jan 28, 2013 at 19:15

2 Answers 2

4

You can always shell out.

system('rails server')

or

`rails server` # backticks
Sign up to request clarification or add additional context in comments.

3 Comments

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?
It's Kernel#system. No, you can't fire multiple servers this way. Unless you fork or multi-thread. See also Dir#chdir
2

The easiest way is to put backticks around the command:

`rails server`

But what are you trying to do?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.