Skip to content

Commit

Permalink
Merge pull request #45163 from HParker/deprecate-plural-association-n…
Browse files Browse the repository at this point in the history
…ames-on-singular-reflections

Deprecate plural association names on singular associations
  • Loading branch information
byroot committed May 31, 2022
2 parents 2d62fd0 + 92eeaff commit e0b58f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/table_metadata.rb
Expand Up @@ -23,7 +23,7 @@ def has_column?(column_name)
end

def associated_with?(table_name)
klass&._reflect_on_association(table_name) || klass&._reflect_on_association(table_name.singularize)
klass&._reflect_on_association(table_name)
end

def associated_table(table_name)
Expand Down
6 changes: 6 additions & 0 deletions activerecord/test/cases/relation/where_test.rb
Expand Up @@ -437,5 +437,11 @@ def test_invert_where

assert_equal 1, posts.invert_where.first.id
end

def test_nested_conditional_on_enum
post = Post.first
Comment.create!(label: :default, post: post, body: "Nice weather today")
assert_equal [post], Post.joins(:comments).where(comments: { label: :default, body: "Nice weather today" }).to_a
end
end
end

0 comments on commit e0b58f6

Please sign in to comment.