[skip ci] Fix examples for has_{one,many} :through :source and :source_type#40320
Merged
kamipo merged 1 commit intorails:masterfrom Nov 25, 2020
Merged
[skip ci] Fix examples for has_{one,many} :through :source and :source_type#40320kamipo merged 1 commit intorails:masterfrom
kamipo merged 1 commit intorails:masterfrom
Conversation
Member
|
Thanks! |
kamipo
added a commit
that referenced
this pull request
Nov 25, 2020
[skip ci] Fix examples for has_{one,many} :through :source and :source_type
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is the first Pull Request which update examples for #35612
The syntax for
has_one :plymophicis not supportedOther Information
The problem of example-for-has-many-source-type
4.3.2.10 :source_type
Steps to reproduce
Actual behavior
$ ruby has_many_polymorphic_association_failure.rb Fetching gem metadata from https://rubygems.org/........ Resolving dependencies... Using concurrent-ruby 1.1.7 Using i18n 1.8.5 Using minitest 5.14.2 Using thread_safe 0.3.6 Using tzinfo 1.2.7 Using zeitwerk 2.4.0 Using activesupport 6.0.0 Using activemodel 6.0.0 Using activerecord 6.0.0 Using bundler 2.1.4 Using sqlite3 1.4.2 -- create_table(:authors, {:force=>true}) D, [2020-10-02T23:54:20.140981 #13635] DEBUG -- : (0.8ms) SELECT sqlite_version(*) D, [2020-10-02T23:54:20.141363 #13635] DEBUG -- : (0.1ms) DROP TABLE IF EXISTS "authors" D, [2020-10-02T23:54:20.141736 #13635] DEBUG -- : (0.3ms) CREATE TABLE "authors" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL) -> 0.0046s -- create_table(:hardbacks, {:force=>true}) D, [2020-10-02T23:54:20.141947 #13635] DEBUG -- : (0.0ms) DROP TABLE IF EXISTS "hardbacks" D, [2020-10-02T23:54:20.142117 #13635] DEBUG -- : (0.1ms) CREATE TABLE "hardbacks" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL) -> 0.0003s -- create_table(:paperbacks, {:force=>true}) D, [2020-10-02T23:54:20.142297 #13635] DEBUG -- : (0.0ms) DROP TABLE IF EXISTS "paperbacks" D, [2020-10-02T23:54:20.142462 #13635] DEBUG -- : (0.1ms) CREATE TABLE "paperbacks" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL) -> 0.0003s -- create_table(:books, {:force=>true}) D, [2020-10-02T23:54:20.142642 #13635] DEBUG -- : (0.0ms) DROP TABLE IF EXISTS "books" D, [2020-10-02T23:54:20.142879 #13635] DEBUG -- : (0.1ms) CREATE TABLE "books" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "author_id" varchar, "format_type" varchar, "format_id" integer) -> 0.0004s D, [2020-10-02T23:54:20.170632 #13635] DEBUG -- : (0.2ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL) D, [2020-10-02T23:54:20.187638 #13635] DEBUG -- : ActiveRecord::InternalMetadata Load (2.0ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]] D, [2020-10-02T23:54:20.191447 #13635] DEBUG -- : (0.1ms) begin transaction D, [2020-10-02T23:54:20.191722 #13635] DEBUG -- : ActiveRecord::InternalMetadata Create (0.1ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "default_env"], ["created_at", "2020-10-02 14:54:20.191083"], ["updated_at", "2020-10-02 14:54:20.191083"]] D, [2020-10-02T23:54:20.191894 #13635] DEBUG -- : (0.0ms) commit transaction Traceback (most recent call last): 8: from has_many_polymorphic_association_failure.rb:51:in `<main>' 7: from has_many_polymorphic_association_failure.rb:52:in `<class:Book>' 6: from /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.0/lib/active_record/associations.rb:1511:in `has_one' 5: from /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.0/lib/active_record/associations/builder/association.rb:30:in `build' 4: from /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.0/lib/active_record/associations/builder/association.rb:40:in `create_reflection' 3: from /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.0/lib/active_record/associations/builder/association.rb:67:in `validate_options' 2: from /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.0/lib/active_support/core_ext/hash/keys.rb:50:in `assert_valid_keys' 1: from /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.0/lib/active_support/core_ext/hash/keys.rb:50:in `each_key' /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.0/lib/active_support/core_ext/hash/keys.rb:52:in `block in assert_valid_keys': Unknown key: :polymorphic. Valid keys are: :class_name, :anonymous_class, :foreign_key, :validate, :autosave, :foreign_type, :dependent, :primary_key, :inverse_of, :required, :as, :touch (ArgumentError)The problem of example-for-has-one-source-type
4.2.2.9 :source_type
Steps to reproduce
Actual behavior
$ ruby has_one_polymorphic_association_failure.rb Fetching gem metadata from https://rubygems.org/........ Resolving dependencies... Using concurrent-ruby 1.1.7 Using i18n 1.8.5 Using minitest 5.14.2 Using thread_safe 0.3.6 Using tzinfo 1.2.7 Using zeitwerk 2.4.0 Using activesupport 6.0.0 Using activemodel 6.0.0 Using activerecord 6.0.0 Using bundler 2.1.4 Using sqlite3 1.4.2 -- create_table(:authors, {:force=>true}) D, [2020-10-02T23:51:26.479832 #13529] DEBUG -- : (1.8ms) SELECT sqlite_version(*) D, [2020-10-02T23:51:26.480490 #13529] DEBUG -- : (0.1ms) DROP TABLE IF EXISTS "authors" D, [2020-10-02T23:51:26.480900 #13529] DEBUG -- : (0.3ms) CREATE TABLE "authors" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL) -> 0.0124s -- create_table(:hardbacks, {:force=>true}) D, [2020-10-02T23:51:26.481160 #13529] DEBUG -- : (0.0ms) DROP TABLE IF EXISTS "hardbacks" D, [2020-10-02T23:51:26.481348 #13529] DEBUG -- : (0.1ms) CREATE TABLE "hardbacks" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL) -> 0.0004s -- create_table(:paperbacks, {:force=>true}) D, [2020-10-02T23:51:26.481572 #13529] DEBUG -- : (0.0ms) DROP TABLE IF EXISTS "paperbacks" D, [2020-10-02T23:51:26.481814 #13529] DEBUG -- : (0.1ms) CREATE TABLE "paperbacks" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL) -> 0.0004s -- create_table(:books, {:force=>true}) D, [2020-10-02T23:51:26.482095 #13529] DEBUG -- : (0.1ms) DROP TABLE IF EXISTS "books" D, [2020-10-02T23:51:26.482315 #13529] DEBUG -- : (0.1ms) CREATE TABLE "books" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "author_id" varchar, "format_type" varchar, "format_id" integer) -> 0.0005s -- create_table(:dust_jackets, {:force=>true}) D, [2020-10-02T23:51:26.482510 #13529] DEBUG -- : (0.0ms) DROP TABLE IF EXISTS "dust_jackets" D, [2020-10-02T23:51:26.482696 #13529] DEBUG -- : (0.1ms) CREATE TABLE "dust_jackets" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "hardback_id" varchar) -> 0.0004s D, [2020-10-02T23:51:26.527559 #13529] DEBUG -- : (0.1ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL) D, [2020-10-02T23:51:26.548122 #13529] DEBUG -- : ActiveRecord::InternalMetadata Load (3.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]] D, [2020-10-02T23:51:26.551712 #13529] DEBUG -- : (0.1ms) begin transaction D, [2020-10-02T23:51:26.552067 #13529] DEBUG -- : ActiveRecord::InternalMetadata Create (0.1ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "default_env"], ["created_at", "2020-10-02 14:51:26.551381"], ["updated_at", "2020-10-02 14:51:26.551381"]] D, [2020-10-02T23:51:26.552271 #13529] DEBUG -- : (0.0ms) commit transaction Traceback (most recent call last): 8: from has_one_polymorphic_association_failure.rb:55:in `<main>' 7: from has_one_polymorphic_association_failure.rb:56:in `<class:Book>' 6: from /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.0/lib/active_record/associations.rb:1511:in `has_one' 5: from /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.0/lib/active_record/associations/builder/association.rb:30:in `build' 4: from /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.0/lib/active_record/associations/builder/association.rb:40:in `create_reflection' 3: from /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.0/lib/active_record/associations/builder/association.rb:67:in `validate_options' 2: from /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.0/lib/active_support/core_ext/hash/keys.rb:50:in `assert_valid_keys' 1: from /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.0/lib/active_support/core_ext/hash/keys.rb:50:in `each_key' /Users/mh/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.0/lib/active_support/core_ext/hash/keys.rb:52:in `block in assert_valid_keys': Unknown key: :polymorphic. Valid keys are: :class_name, :anonymous_class, :foreign_key, :validate, :autosave, :foreign_type, :dependent, :primary_key, :inverse_of, :required, :as, :touch (ArgumentError)