Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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