Skip to content

Instantly share code, notes, and snippets.

@meriy100
Last active January 17, 2018 15:08
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 meriy100/b04ef9bddea0347bd2546593f9be004c to your computer and use it in GitHub Desktop.
Save meriy100/b04ef9bddea0347bd2546593f9be004c to your computer and use it in GitHub Desktop.
ActiveRecord だけを使いたいとき ref: https://qiita.com/meriy100/items/4e1a74334314ed587862
require 'active_record'
# Rails で言うところの config/database.yml
ActiveRecord::Base.establish_connection(
adapter: 'mysql2',
host: 'localhost',
username: 'username',
password: 'password',
database: 'database',
# ....
)
# 使いたいテーブルのモデル
class User < ActiveRecord::Base
# relation とか
end
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment