Last active
April 8, 2024 18:01
-
-
Save fixlr/370723dc107b4ed780e6cc53357387d2 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
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
gem "rails" | |
# If you want to test against edge Rails replace the previous line with this: | |
# gem "rails", github: "rails/rails", branch: "main" | |
gem "sqlite3" | |
end | |
require "active_record" | |
require "minitest/autorun" | |
require "logger" | |
# This connection will do for database-independent bug reports. | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table :responses, force: true do |t| | |
t.integer :client_id, null: false | |
end | |
create_table :clients, force: true do |t| | |
end | |
end | |
class Response < ActiveRecord::Base | |
belongs_to :client | |
end | |
class Client < ActiveRecord::Base | |
has_many :response | |
has_one :response | |
end | |
class BugTest < Minitest::Test | |
def test_association_stuff | |
client = Client.create! | |
client.create_response! | |
# NoMethodError: undefined method `find_all' for #<Response> | |
client.save! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment