Skip to content

Instantly share code, notes, and snippets.

@calebhaye
Created January 22, 2016 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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