Skip to content

Instantly share code, notes, and snippets.

@328
Created October 24, 2016 01:10
Show Gist options
  • Save 328/b8b3f9267023adb717a333b72f8b1e3e to your computer and use it in GitHub Desktop.
Save 328/b8b3f9267023adb717a333b72f8b1e3e to your computer and use it in GitHub Desktop.
rubyからPostgreSQLに接続するためのコード
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