Skip to content

Instantly share code, notes, and snippets.

@aergonaut
Created October 23, 2020 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aergonaut/feb075f3eeda35eaf751d967d01fe181 to your computer and use it in GitHub Desktop.
Save aergonaut/feb075f3eeda35eaf751d967d01fe181 to your computer and use it in GitHub Desktop.
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "activerecord", "~> 6"
gem "sqlite3"
gem "protected_attributes_continued", "1.6.0"
end
require "active_record"
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
ActiveRecord::Schema.define do
create_table :users, force: true do
end
create_table :comments, force: true do |t|
t.belongs_to :user
end
end
class User < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :user
end
User.new.comments.where("1=1").first_or_initialize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment