Last active
January 17, 2018 15:08
-
-
Save meriy100/b04ef9bddea0347bd2546593f9be004c to your computer and use it in GitHub Desktop.
ActiveRecord だけを使いたいとき ref: https://qiita.com/meriy100/items/4e1a74334314ed587862
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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