Skip to content

Instantly share code, notes, and snippets.

@valk
Created June 12, 2013 19:22
Show Gist options
  • Save valk/5768297 to your computer and use it in GitHub Desktop.
Save valk/5768297 to your computer and use it in GitHub Desktop.
How to run Rails server and perform other commands from a Ruby script file.
#!/usr/bin/env ruby
# Put this file in /script/ directory.
require 'rails/commands/server'
Rails::Server.new.tap { |server|
APP_PATH = File.expand_path('../../config/application', __FILE__)
require APP_PATH
Dir.chdir(Rails.application.root)
server.start
}
puts "Your code which requires the server in action goes here..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment