You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
beginrequire'bundler/inline'rescueLoadError=>e
$stderr.puts'Bundler version 1.10 or later is required. Please update your Bundler'raiseeendgemfile(true)dosource'https://rubygems.org'# Activate the gem you are reporting the issue against.gem'activerecord','4.2.5'gem'sqlite3'endrequire'active_record'require'minitest/autorun'require'logger'# Ensure backward compatibility with Minitest 4Minitest::Test=MiniTest::Unit::TestCaseunlessdefined?(Minitest::Test)# 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.definedocreate_table:postscreate_table:commentsdo |t|
t.belongs_to:commentable,polymorphic: trueendendclassComment < ActiveRecord::Basebelongs_to:commentable,polymorphic: truebelongs_to:post,->ownerdoifowner.is_a?(Comment)# calling assocowner.commentable_type == 'Post' ? Post.all : Post.noneelse# joiningwhere(comments: {commentable_type: 'Post'})endend,foreign_key: :commentable_idendclassPost < ActiveRecord::Basehas_many:comments,as: :commentableendclassBugTest < Minitest::Testdeftest_association_stuffc=Comment.create!p=Post.create!comments: [c]assertc.postassert_equal1,Comment.joins(:post).countendend
The text was updated successfully, but these errors were encountered:
It is working only because you are handling the case where owner is not present. We don't think it is a good idea to join associations like this one so it we will keep it deprecated. Thank you
because you are handling the case where owner is not present
Yes, you have to handle both cases, but why is that a bad thing?
We don't think it is a good idea to join associations like this one
Why don't you think it's a good idea? The alternative is to create two associations, one that only works for joins and another that only works for instance invoke. Is that supposed to be better that one association that can do both?
Thank you
Is that a sincere thank you for creating a good bug report?
Yes, you have to handle both cases, but why is that a bad thing?
Because you would have to remember that.
Why don't you think it's a good idea?
The main reason it is because it is confusing, a user would have to know about this special case were the instance is not passed to the association. Other reason to deprecate it is because it is surprising.
The alternative is to create two associations, one that only works for joins and another that only works for instance invoke. Is that supposed to be better that one association that can do both?
Other alternative is doing the join in the table instead of in the association.
See the original issue for more background about the deprecation. #15024.
Is that a sincere thank you for creating a good bug report?
The text was updated successfully, but these errors were encountered: