Skip to content

Instantly share code, notes, and snippets.

@mechamogera
Created September 4, 2012 08:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mechamogera/3618377 to your computer and use it in GitHub Desktop.
rails外のスクリプトからモデルを使用してみる
#!/bin/env ruby
RAILS_BASE = "/my/rails/dir/"
require RAILS_BASE + 'config/environment'
dbconfig = YAML.load_file(RAILS_BASE + 'config/database.yml')['production']
ActiveRecord::Base.establish_connection(dbconfig)
p User.all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment