Skip to content

Instantly share code, notes, and snippets.

@calebhaye
Created January 22, 2016 22:54
Show Gist options
  • Save calebhaye/0c4af4db17f24193c2c2 to your computer and use it in GitHub Desktop.
Save calebhaye/0c4af4db17f24193c2c2 to your computer and use it in GitHub Desktop.
Rails from Bash / Shell
#!/usr/bin/env ruby
begin
puts "Loading Rails..."
require File.join('.', 'config', 'application')
require File.join('.', 'config', 'boot')
Rails.application.require_environment!
rescue
$stderr.puts "Please run #{$0} in your Rails root."
exit 1
end
puts "Rails is ready."
puts "User.count: #{User.count}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment