1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #43069 from p8/activerecord/improve-where-docs-with-hash

Don't use redundant curly braces in `where` examples [ci-skip]
This commit is contained in:
Jonathan Hefner 2021-08-22 12:02:36 -05:00 committed by GitHub
commit 99c67db17d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -653,13 +653,13 @@ module ActiveRecord
#
# Fields can be symbols or strings. Values can be single values, arrays, or ranges.
#
# User.where({ name: "Joe", email: "joe@example.com" })
# User.where(name: "Joe", email: "joe@example.com")
# # SELECT * FROM users WHERE name = 'Joe' AND email = 'joe@example.com'
#
# User.where({ name: ["Alice", "Bob"]})
# User.where(name: ["Alice", "Bob"])
# # SELECT * FROM users WHERE name IN ('Alice', 'Bob')
#
# User.where({ created_at: (Time.now.midnight - 1.day)..Time.now.midnight })
# User.where(created_at: (Time.now.midnight - 1.day)..Time.now.midnight)
# # SELECT * FROM users WHERE (created_at BETWEEN '2012-06-09 07:00:00.000000' AND '2012-06-10 07:00:00.000000')
#
# In the case of a belongs_to relationship, an association key can be used
@ -689,8 +689,8 @@ module ActiveRecord
#
# For hash conditions, you can either use the table name in the key, or use a sub-hash.
#
# User.joins(:posts).where({ "posts.published" => true })
# User.joins(:posts).where({ posts: { published: true } })
# User.joins(:posts).where("posts.published" => true)
# User.joins(:posts).where(posts: { published: true })
#
# === no argument
#