Rails beginner
Rails beginner

Reputation: 14504

Ruby - How to run rails console commands inside ruby file?

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

Upvotes: 0

Views: 433

Answers (2)

Sergio Tulentsev
Sergio Tulentsev

Reputation: 230286

You can always shell out.

system('rails server')

or

`rails server` # backticks

Upvotes: 4

Zach Kemp
Zach Kemp

Reputation: 11904

The easiest way is to put backticks around the command:

`rails server`

But what are you trying to do?

Upvotes: 2

Related Questions