Created
October 23, 2020 16:48
-
-
Save aergonaut/feb075f3eeda35eaf751d967d01fe181 to your computer and use it in GitHub Desktop.
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 "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