Skip to content

Instantly share code, notes, and snippets.

@KitaitiMakoto
Created May 5, 2017 19:11
Show Gist options
  • Save KitaitiMakoto/2f6826d4c2a4477d0528b4b8b1e2f8af to your computer and use it in GitHub Desktop.
Save KitaitiMakoto/2f6826d4c2a4477d0528b4b8b1e2f8af to your computer and use it in GitHub Desktop.
require "active_record"
config = {
adapter: "sqlserver",
host: "localhost",
port: 1433,
username: "sa",
password: "yourStrong(!)Password",
database: "groupby"
}
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :role
end
end
end
class User < ActiveRecord::Base
end
ActiveRecord::Base.establish_connection config
unless ActiveRecord::Base.connection.data_source_exists? :users
CreateUsers.new.change
3.times do
User.create(role: "member")
User.create(role: "admin")
end
end
p User.group(:role)
p User.group(:role).exists?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment