Created
October 13, 2014 04:55
-
-
Save miyohide/2c8cefb2009cae2dcd95 to your computer and use it in GitHub Desktop.
ActiveRecordを単独で使用するサンプル
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" | |
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