Skip to content

Instantly share code, notes, and snippets.

@miyohide
Created October 13, 2014 04:55
Show Gist options
  • Save miyohide/2c8cefb2009cae2dcd95 to your computer and use it in GitHub Desktop.
Save miyohide/2c8cefb2009cae2dcd95 to your computer and use it in GitHub Desktop.
ActiveRecordを単独で使用するサンプル
require "active_record"
require "faker"
ActiveRecord::Base.establish_connection(
adapter: "postgresql",
host: "localhost",
username: "username",
password: "password",
database: "sample_db"
)
class Posts < ActiveRecord::Base
end
10.times do |i|
Posts.create(id: i+100, title: Faker::Lorem.word, body: Faker::Lorem.paragraph)
end
p Posts.count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment