Skip to content

Instantly share code, notes, and snippets.

@mechamogera
Created September 4, 2012 08:14
Show Gist options
  • Save mechamogera/3618377 to your computer and use it in GitHub Desktop.
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