Created
October 24, 2016 01:10
-
-
Save 328/b8b3f9267023adb717a333b72f8b1e3e to your computer and use it in GitHub Desktop.
rubyからPostgreSQLに接続するためのコード
This file contains hidden or 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 'pg' | |
require "active_record" | |
ActiveRecord::Base.establish_connection( | |
:adapter=>"postgresql", | |
:database =>"postgres", | |
:username=>"postgres", | |
:password=>"password", | |
) | |
class User < ActiveRecord::Base | |
self.table_name = 'users' | |
end | |
p User.all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment